首页 文章

当app处于关闭状态时,Onesignal推送通知不适用于离子应用程序

提问于
浏览
0

我正在使用基于离子cordova的Android应用程序的OneSignal推送通知 . 当应用程序处于关闭状态时,我正在努力处理发送推送通知 . 我遵循oneSignal通知站点的所有进程 . 是的,当app处于运行状态或应用程序处于后台模式时,推送通知运行良好 . 我在我的项目中添加了“cordova插件添加onesignal-cordova-plugin” . 还在我的app.js中添加了通知代码以下是代码片段

document.addEventListener('deviceready', function () {
            // Enable to debug issues.
            // window.plugins.OneSignal.setLogLevel({logLevel: 4, visualLevel: 4});

            var notificationOpenedCallback = function(jsonData) {
                console.log('didReceiveRemoteNotificationCallBack: ' + JSON.stringify(jsonData));
            };

            window.plugins.OneSignal.init("3......<NOT-SHARED>",
                {googleProjectNumber: "963........"},
                notificationOpenedCallback);

            // Show an alert box if a notification comes in when the user is in your app.
            window.plugins.OneSignal.enableInAppAlertNotification(true);
        }, false);

请帮我解决这个问题..谢谢你

1 回答

  • 0

    您的应用似乎可能会进入“强制停止”状态 . 你是如何关闭你的应用程序的?将其从“最近的应用”列表中轻扫,从“设置”>“应用”,然后按“强制停止”按钮或其他第三方任务管理器?

    发送推送通知以确认问题是“强制停止”状态时,请检查位置以查找以下条目 .

    /** 2.2 Sent notification, GCM Message payload was received by Google Play services on the device. **/
    02-27 13:44:54.019 2630-31453/? I/GCM: GCM message com.onesignal.example 0:1456609494311032%616610ddf9fd7ecd
    /** 2.3 Google Play services couldn't wake the app as "result=CANCELLED" is in the intent callback. **/
    02-27 13:44:54.044 2630-2630/? W/GCM-DMM: broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE pkg=com.onesignal.example (has extras) }
    

    https://gist.github.com/jkasten2/fb83b1df754cf26df378

相关问题