添加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应用程序无法启动 的相关文章

  • Firebase 如何取消订阅

    我在用Ionic2 with Angularfire2访问Firebase Authentication 我访问以下内容rxjs Observable chats ts this firelist this dataService find
  • 调整离子卡中的图像大小

    我想显示一组图像 并在下面说明 我选择使用 Ionic 卡 我得到这个结果 第一张图片 虽然我想保留现在的相同布局 并添加描述 这是我的代码
  • 所有 'size' 、 'prototype' 的声明必须具有相同的修饰符

    I have downloaded code from repository and run it on local getting these errors have following versions when i run ionic
  • ionic 2 google 图表未捕获类型错误:(void 0) 不是函数

    error 我想添加谷歌图表并按照这个https www npmjs com package angular2 google chart https www npmjs com package angular2 google chart 但
  • 如何重启ngOnInit来更新Interpolation

    有办法重新启动吗ngOnInit 改变变量时 因为我想重新开始ngOnInit 改变时theme多变的 这是我的代码 设置 ts export class SettingsPage implements OnInit phraseColor
  • 收到 fcm 推送通知时设置应用程序徽章

    我正在使用 FCM 进行云消息传递 当我在后台和前台应用程序状态下收到来自服务器的推送通知时 我想添加应用程序徽章 我缺少什么 主要问题是根据推送通知添加 更新 删除应用程序徽章 我可以接收和处理推送消息 我在这个问题上花了 3 天 请帮帮
  • 运行时推送通知(GCM)权限?

    我读到 对于 API 23 及更高版本 有必要在运行时向用户询问一些权限 例如 android permission ACCESS FINE LOCATION 如果 API 为 23 或更高版本 是否有必要 甚至可能 在运行时请求使用 GC
  • 在前台显示通知 React Native Firebase v6

    我正在使用最新的 React Native 版本 0 62 和最新版本的 React Native Firebase 即 v6 我能够收到通知 它在后台工作正常 但不显示在前台 Here is the screenshot 这是我的代码 c
  • Firebase:即使应用程序退出也会监听 ChildEventListener

    我正在研究一个iOS应用程序 并希望使用 firebase 实时数据库实现推送通知等行为 如果我的应用程序正在侦听某些 Firebase 节点 并且在该节点更新时我将向用户发送本地推送通知 问题是 如果应用程序未运行 即用户已终止它 我的应
  • 离子标签栏与主页按钮重叠(iPhone X - iOS 11)

    使用 iOS 11 和 iPhone X苹果指定 https developer apple com ios human interface guidelines overview iphone x 每个应用程序都应该位于 安全区域 由于虚
  • 延迟推送通知并检查用户是否启用它

    我开发了一个应用程序 它围绕推送通知构建 仅当用户达到注册过程的某个阶段时 应用程序才会请求通知权限 我已经设法做到了以下几点 该应用程序维护一个NSUserDefaults变量 指示是否需要在启动时注册推送 默认情况 不需要 当注册达到该
  • 前台通知 android 未显示(奥利奥)

    当应用程序位于前景 当我从服务器推送通知时 会调用 onMessageReceived 方法 但是通知不显示 这是我的代码 public class MyFirebaseMessagingService extends FirebaseMe
  • ionic2 对菜单项应用 ngx-translate

    我正在使用 ngx translate 来支持多语言 并且运行良好 但我也想申请菜单项 我该如何实现这一目标 我有 3 个菜单项 我想更改每个标题的语言 ts file appPages PageObj title Profile comp
  • 使用 Phaser.js 和 Ionic 开发游戏应用程序(渲染缓慢/不稳定)

    只是为了让您知道 以防有人想要开发 我使用 Phaser js 开发了一个游戏应用程序 我将代码放入 Ionic 空白启动应用程序中 所以基本上视图是使用 Ionic 应用程序渲染的 然后 Phaser 通过 id 选取 div 并显示游戏
  • 如何在 angularjs 4 中设置 http 调用超时?

    我在 angularjs 4 官方页面上看到过 https angular io guide http https angular io guide http 设置http调用超时但我没有找到任何参考 有人尝试过设置吗 谢谢 如果您使用 R
  • CloudKit 通过 cron 作业发送推送通知?

    我正在创建一个大学餐饮菜单应用程序 在其中我需要根据每日菜单发送推送通知 最初 我计划通过 Heroku 将用户数据存储在数据库中 并使用 cron 作业将数据库中的数据与每日菜单进行比较 并向用户发送适当的通知 然而 在 Cloudkit
  • 错误:[$rootScope:infdig] 过滤器中发生了 10 次 $digest() 迭代

    我已尝试了有关此问题的所有答案 但找不到消除此错误的方法 我非常确定这个过滤器函数是导致上述错误的原因 filter collect ingredients function return function input if angular
  • ionic:在哪里可以看到显示的控制台日志

    我是 ionic 新手 我正在关注离子框架文档 https ionicframework com docs api components action sheet ActionSheetController 去学习它 这是我的方法的代码 你
  • 如何检查 iOS 分发配置文件是否启用了推送通知?

    我有一个应用程序应该启用推送通知 但由于某种原因没有启用它们 我见过其他人下载并安装了该应用程序 但它甚至没有提示他们授予发送推送通知的权限 正如预期的那样 此应用程序不会出现在其 设置 gt 通知 中 但是 在我的 iPad 上 我能够从
  • SQLite中的ROWID是自动设置的吗?

    所以 我在 Ionic 上有这个应用程序 它使用SQLite ngCordova 插件 https github com litehelpers Cordova sqlite storage用于内部存储 在其上 我使用以下命令创建一个表 d

随机推荐