我有一个ionic 应用程序.我用Xcode为iOS编译了这段代码,它很管用.我还为该应用程序创建了一个小部件.我的愿望是,如果应用程序以正常的应用程序图标打开,主屏幕应该会出现.然而,如果它是用小部件打开的,它将重定向到另一个页面.我怎么能做到这一点?我试了很多方法,但都找不到解决办法.
为此,我试图在TypeScrip端创建一个服务并在那里进行路由,但我不能在这里运行TypeScrip中的代码.
博士:
import { registerPlugin } from '@capacitor/core';
import { NavController } from '@ionic/angular';
// Define the interface
export interface MyServicePlugin {
routeProfile(): any;
routePage(): any;
}
// Implement the class
export class MyService implements MyServicePlugin {
constructor(
private navCtrl: NavController
) { }
routeProfile() {
console.log("sssssssss")
return this.navCtrl.navigateForward(['/login-control']);
}
routePage() {
console.log("ddddddd")
return this.navCtrl.navigateForward(['/login-control']);
}
}
const myService = registerPlugin<MyServicePlugin>('MyService');
export default myService;说
SWIFT代码:
import Foundation
import Capacitor
@objc(MyService)
public class MyService: CAPPlugin {
@objc func routePage(_ call: CAPPluginCall) {
}
@objc func routeProfile(_ call: CAPPluginCall) {
if let viewController = self.bridge?.viewController {
//viewController.performSegue(withIdentifier: "/login-control", sender: nil)
call.resolve([:])
} else {
call.reject("NavController is not available.")
}
}
}
说
我在设备方面的结果:
To Native -> MyService routeProfile 134138947