Rohit Deshmukh
Rohit Deshmukh

Reputation: 384

Onesignal push notification is not working with ionic app when app is in closed state

I am working with OneSignal push notification for ionic cordova based android application.I am struggling with send push notification when app in closed state.I followed all process from oneSignal notification site. Yes,Push notification worked well when app in running state or app in background mode. I added "cordova plugin add onesignal-cordova-plugin" in my project.Also added code for notification in my app.js following is the code snippet

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);

Please help me to resolve this issue.. Thanks in adv

Upvotes: 0

Views: 1857

Answers (1)

jkasten
jkasten

Reputation: 3948

It seems like your app might be getting into a "Force Stopped" state. How are you closing your app? Swiping it away from the Recent Apps list, from Settings>Apps then pressing the "Force stop" button, or another 3rd party task manager?

Check the locat for the following entries when you send a push notification to confirm the issue is the "Force Stopped" state.

/** 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

Upvotes: 0

Related Questions