添加phonegap-plugin-push插件后Ionic应用程序无法启动

2024-01-23

在我尝试按照此处的指南添加phonegap-plugin-push插件后,我的Ionic应用程序卡在启动屏幕上:https://ionicframework.com/docs/native/push/ https://ionicframework.com/docs/native/push/

我尝试删除和添加平台,删除和添加phonegap-plugin-push插件,结果是一致的 - 只要将推送插件添加到我的项目中,应用程序就会在启动屏幕时默默地失败,而不会出现错误。

这是 app.component.ts 中的代码:

  constructor(
    public events: Events,
    public userData: UserData,
    public menu: MenuController,
    public platform: Platform,
    public parseData: ParseData,
    public storage: Storage,
    public splashScreen: SplashScreen,
    private iab: InAppBrowser,
    private push: Push
  ) {
    this.platform.ready().then(() => {
      console.log("platform ready called");
      this.nav.setRoot(TabsPage);
      this.menu.enable(true);
      this.splashScreen.hide();
      console.log("splash screen hide called");
    });
  }

  handlePush(){
    // to check if we have permission
    this.push.hasPermission()
      .then((res: any) => {

        if (res.isEnabled) {
          console.log('We have permission to send push notifications');
        } else {
          console.log('We do not have permission to send push notifications');
        }

      });

    // to initialize push notifications

    const options: PushOptions = {
       android: {
           senderID: '12345679'
       },
       ios: {
           alert: 'true',
           badge: true,
           sound: 'false'
       },
       windows: {}
    };

    const pushObject: PushObject = this.push.init(options);

    pushObject.on('notification').subscribe((notification: any) => console.log('Received a notification', notification));

    pushObject.on('registration').subscribe((registration: any) => console.log('Device registered', registration));

    pushObject.on('error').subscribe(error => console.error('Error with Push plugin', error));
  }

整个构造函数方法不再被调用!

这是运行应用程序时输出的日志:

2017-07-18 10:46:07.713123+0800 MY APP[669:222813] DiskCookieStorage changing policy from 2 to 0, cookie file: file:///private/var/mobile/Containers/Data/Application/18A748C9-06F2-438C-9F80-97BC122F5DDD/Library/Cookies/Cookies.binarycookies
2017-07-18 10:46:07.859886+0800 MY APP[669:222813] Apache Cordova native platform version 4.3.1 is starting.
2017-07-18 10:46:07.861502+0800 MY APP[669:222813] Multi-tasking -> Device: YES, App: YES
[INFO] GCDWebServer started on port 8080 and reachable at http://localhost:8080/
2017-07-18 10:46:07.899749+0800 MY APP[669:222813] CDVWKWebViewEngine: trying to inject XHR polyfill
2017-07-18 10:46:08.073686+0800 MY APP[669:222813] CDVWKWebViewEngine will reload WKWebView if required on resume
2017-07-18 10:46:08.073838+0800 MY APP[669:222813] Using Ionic WKWebView
2017-07-18 10:46:08.076407+0800 MY APP[669:222813] [CDVTimer][handleopenurl] 0.579000ms
2017-07-18 10:46:08.084461+0800 MY APP[669:222813] Unlimited access to network resources
2017-07-18 10:46:08.084753+0800 MY APP[669:222813] [CDVTimer][intentandnavigationfilter] 8.060038ms
2017-07-18 10:46:08.085132+0800 MY APP[669:222813] [CDVTimer][gesturehandler] 0.271976ms
2017-07-18 10:46:08.116414+0800 MY APP[669:222813] [CDVTimer][splashscreen] 31.165004ms
2017-07-18 10:46:08.123277+0800 MY APP[669:222813] [CDVTimer][statusbar] 6.673992ms
2017-07-18 10:46:08.127933+0800 MY APP[669:222813] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2017-07-18 10:46:08.129235+0800 MY APP[669:222813] [MC] Filtering mail sheet accounts for bundle ID: com.company.myapp, source account management: 1
2017-07-18 10:46:08.138180+0800 MY APP[669:222813] [MC] Result: NO
2017-07-18 10:46:08.138302+0800 MY APP[669:222813] [CDVTimer][socialsharing] 14.827967ms
2017-07-18 10:46:08.141556+0800 MY APP[669:222813] [CDVTimer][keyboard] 2.990007ms
2017-07-18 10:46:08.141773+0800 MY APP[669:222813] [CDVTimer][TotalPluginStartup] 66.100001ms
2017-07-18 10:46:08.161063+0800 MY APP[669:222813] createNotificationChecker
2017-07-18 10:46:08.161188+0800 MY APP[669:222813] not coldstart
2017-07-18 10:46:08.166413+0800 MY APP[669:222813] active
2017-07-18 10:46:08.168947+0800 MY APP[669:222813] PushPlugin skip clear badge
2017-07-18 10:46:10.731652+0800 MY APP[669:222813] Ionic Native: deviceready event fired after 781 ms

离子信息:

Cordova CLI: 6.5.0 
Ionic Framework Version: 3.3.0
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.3.7
ios-deploy version: 1.9.1 
ios-sim version: 6.0.0 
OS: macOS Sierra
Node Version: v7.6.0
Xcode version: Xcode 8.3.3 Build version 8E3004b

离子平台列表:

Installed platforms:
  android 6.1.0
  ios 4.3.1

推送插件版本为1.10.5:

phonegap-plugin-push 1.10.5 "PushPlugin"

我发现您正在使用 wkwebview 插件。由于这个插件,我在启动屏幕时遇到了冻结。删除它对我有帮助。希望它也能帮助你。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

添加phonegap-plugin-push插件后Ionic应用程序无法启动 的相关文章

随机推荐