首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >添加phonegap- plugin -push插件后,Ionic应用无法启动

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

Stack Overflow用户
提问于 2017-07-18 10:53:26
回答 2查看 637关注 0票数 2

在我尝试添加phonegap- plugin -push插件后,我的离子应用程序在splashscreen上停滞不前,如下指南:https://ionicframework.com/docs/native/push/

我试着移除和添加平台,移除和添加phonegap- plugin -push插件,结果是一致的-只要push插件被添加到我的项目中,应用程序在启动屏幕时就会静默地失败而没有错误。

以下是app.component.ts上的代码:

代码语言:javascript
复制
  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));
  }

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

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

代码语言:javascript
复制
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

离子信息:

代码语言:javascript
复制
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

离子平台列表:

代码语言:javascript
复制
Installed platforms:
  android 6.1.0
  ios 4.3.1

推流插件版本为1.10.5:

代码语言:javascript
复制
phonegap-plugin-push 1.10.5 "PushPlugin"
EN

回答 2

Stack Overflow用户

发布于 2017-07-18 13:37:52

我看到你在使用wkwebview插件。由于这个插件,我遇到了启动画面冻结的问题。移除它对我很有帮助。希望这对你也有帮助。

票数 0
EN

Stack Overflow用户

发布于 2017-07-19 11:50:11

我找到问题了。我按照ionic native documentation安装了@ionic-native/push插件--示例代码中的语法导致了这个问题。只要我切换到v1.x guide中的示例代码,问题就会消失。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45156690

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档