Pushwoosh / pushwoosh-phonegap-plugin

Pushwoosh PhoneGap Build Plugin
Other
109 stars 139 forks source link

Not receiving Push notification on Android #304

Closed zabojad closed 5 years ago

zabojad commented 5 years ago

For some reason I do not understand, I do not receive PN on my Android device.

I did configure GCM in console.firebase.google.com.

I did put the generated google-services.json file in the platform/android folder of my cordova project.

I of course installed the pushwoosh-phonegap-plugin.

I added and call this code at the bootstrap of my app:

function initPushwoosh(store:js.redux.ReduxStore<veditec.state.State>) {
        var pushwoosh = cordova.require("pushwoosh-cordova-plugin.PushNotification");

        // Should be called before pushwoosh.onDeviceReady
        document.addEventListener('push-notification', function(event) {
            console.log('RECEIVED PN: ',event);
        });

        // Initialize Pushwoosh. This will trigger all pending push notifications on start.
        pushwoosh.onDeviceReady({
            appid: "...",
            projectid: "..."
        });

        if (myApp.pnToken == null) {
            pushwoosh.registerDevice(
                function(status) {
                    var pushToken = status.pushToken;
                    console.log('received token',pushToken);
                },
                function(status) {
                    console.error(status);
                }
            );
        }
        else {
            pushwoosh.getPushwooshHWID(function(pwid){console.log('PUSHWOOSH ID: ',pwid);});
        }
    }

At runtime, I see that my app successfully subscribe to PUSHWOOSH (I receive a pw token and have a pw client id) and I see my unique test Android device in the Android "subscribers" count in the Pushwoosh admin interface.

However, the "push-notification" event is never triggered when I send a sample notif from the PW admin interface...

What could be wrong?

zabojad commented 5 years ago

Here are some more info with a portion of the logcats:

01-17 11:26:57.144 9254-9653/my.app D/Pushwoosh: [CordovaPlugin] Plugin Method Called: onDeviceReady
01-17 11:26:57.145 9254-9653/my.app I/Pushwoosh: [NotificationManager] App ID: XXXXX-XXXXX
01-17 11:26:57.147 9254-9653/my.app I/Pushwoosh: [NotificationManager] Sender ID: XXXXXXXXXX
01-17 11:26:57.149 9254-9254/my.app D/Pushwoosh: onAppReady
    sendAppOpenEndTagMigrate
01-17 11:26:57.154 9254-9653/my.app D/Pushwoosh: [CordovaPlugin] Plugin Method Called: getPushwooshHWID
01-17 11:26:57.160 9254-9254/my.app D/Pushwoosh: [[BusinessCase]] trigger welcome-inapp
    [BusinessCase] welcome-inapp condition not satisfied
    [[BusinessCase]] trigger app-update-message
01-17 11:26:57.161 9254-9254/my.app D/Pushwoosh: [BusinessCase] app-update-message condition not satisfied
01-17 11:26:57.172 9254-9254/my.app D/Pushwoosh: [JobServiceEngineImpl] onStartJob: android.app.job.JobParameters@344323
01-17 11:26:57.183 9254-18165/my.app D/Pushwoosh: [RequestManager] Try To send: applicationOpen; baseUrl: https://DB224-ABAD6.api.pushwoosh.com/json/1.3/

01-17 11:26:57.588 9254-18165/my.app I/Pushwoosh: [RequestManager] 
    x
    |     Pushwoosh request:
    | Url: https://xxxxx.api.pushwoosh.com/json/1.3/applicationOpen
    | Payload: {"request":{"application":"XXXXXX","hwid":"xxxxxx","v":"5.11.0","device_type":3,"userId":"xxxxx","device_name":"Phone","language":"fr","timezone":3600,"android_package":"my.app","jailbroken":1,"device_model":"Samsung SM-G950F","os_version":"8.0.0","app_version":"1.3.4","notificationTypes":6}}
    | Response: {"status_code":200,"status_message":"OK","response":{"required_inapps":[]}}
    x
zabojad commented 5 years ago

Is platform/android the right place for the google-services.json file ?

zabojad commented 5 years ago

@kaizerzer would you have any idea on this issue?

zabojad commented 5 years ago

Other question: is any of those steps needed with the cordova plugin?

wfhm commented 5 years ago

@zabojad

First, all the required steps to integrate pushwoosh-cordova-plugin are described here. There is no need to worry about google-services.json file, you should basically just specify your Project number (FCM Sender ID) in pushwoosh.onDeviceReady parameters. Additionally, you have to create a Firebase project in Firebase console and configure it as described in this guide.

Further resolution of this issue might require accessing sensitive information, such as your App ID and account name, therefore may I ask you to create a support ticket via Contact us form, provide us with your Pushwoosh account name and App ID so we could check if pushes were sent correctly from our backend and mention this issue in your request?

zabojad commented 5 years ago

Hi @wfhm ! Yes the support already answered to me so I'm closing this ticket here on Github. Thanks !

CodeWithOz commented 3 years ago

@zabojad I seem to be experiencing a similar issue, where notifications are getting delayed for a very long time (30-45 mins) before they show up on the device, even though they're marked as delivered almost immediately in the pushwoosh dashboard. Can you share what the cause of your problem was? Thanks.

wfhm commented 3 years ago

@CodeWithOz The Success report in the Control Panel indicates that a push was delivered to the gateway, not to the device itself.

I seem to be experiencing a similar issue, where notifications are getting delayed for a very long time (30-45 mins) before they show up on the device

Android OS can delay or even cancel notifications depending on a device state. Could you please check whether your device has any power-saving options enabled?