freshworks / hotline-phonegap

Hotline Phonegap Plugin
https://hotline.io
Other
6 stars 11 forks source link

Android Notification fails #10

Closed theavijitsarkar closed 8 years ago

theavijitsarkar commented 8 years ago

When I activate notifcations android app fails completely.

java.lang.IncompatibleClassChangeError: android.support.v4.content.ContextCompat

    at com.freshdesk.hotline.android.HotlineGcmRegistrationService.onHandleIntent(HotlineGcmRegistrationService.java:26)
rsquare2014 commented 8 years ago

can you please tell us the version of play services that you are including with your cordova application

theavijitsarkar commented 8 years ago

how to find that out?

hrishikesh-p commented 8 years ago

Please update to the latest SDK version and let us know if you are still facing any issues..

We made some major changes to how we handle push notification. Please refer -> https://github.com/freshdesk/hotline-phonegap/blob/master/README.md

theavijitsarkar commented 8 years ago

The problem is not solved. It is bypassed. My issue is that I use onesignal for notifications. Now I cant run both onesignal and push plugin together, I tried but the app now receives two copies for each message.

hrishikesh-p commented 8 years ago

ok .. if you don't want to use the push plugin .. you can remove that ..

You just need to make sure Hotline.updateRegistrationToken is called when you receive a push token

and

Hotline.handlePushNotification is called when a push notification is received.

It should work fine.

hrishikesh-p commented 8 years ago

@snowbreeze I have reopened this issue . Please check and let us know.

theavijitsarkar commented 8 years ago

Ok let me try

theavijitsarkar commented 8 years ago

I modified the OneSignal to pass the incoming data to hotline, However now no messages come from hotline the notificationReceived callback is never called. I tested it directly in that case it works.

var notificationReceived = function(data) {
                console.log('didReceiveRemoteNotificationCallBack: ' + JSON.stringify(data));
                window.Hotline.isHotlinePushNotification(data.additionalData, function(success, isHotlineNotif) {
                    if (success && isHotlineNotif) {
                        window.Hotline.handlePush(data.additionalData);
                    }
                });

            };
  window.plugins.OneSignal
                .startInit("41952347-57d7-49b4-a520-aa5a1a969c42", "743540710589")
                .handleNotificationReceived(notificationReceived)
                .handleNotificationOpened(notificationOpenedCallback)
                .endInit();

            window.plugins.OneSignal.getIds(function(ids) {
                console.log('getIds: ' + JSON.stringify(ids));
                //alert("userId = " + ids.userId + ", pushToken = " + ids.pushToken);
                window.Hotline.updateRegistrationToken(ids.pushToken);
            });

OUTPUT IS

didReceiveRemoteNotificationCallBack: {"isAppInFocus":false,"shown":true,"androidNotificationId":-XXXX,"payload":{"lockScreenVisibility":1,"rawPayload":"{\"google.sent_time\":XXX,\"notificationId\":-XXX,\"title\":\"Demo DEMO\",\"collapse_key\":\"do_not_collapse\",\"alert\":\"dedasd asdasd asd asd\",\"from\":\"XXXXXXXX\",\"google.message_id\":\"0:XXXX%XX\",\"custom\":\"{\\\"i\\\":\\\"XX-839b-4445-85c3-XX\\\"}\"}","body":"dedasd asdasd asd asd","title":"Demo DEMO","notificationID":"XX-839b-4445-85c3-XXX","fromProjectNumber":"XXXXXX"},"displayType":0} 

Note: I dont see the additional in the json, will that only come if hotline sends it

rsquare2014 commented 8 years ago

Hey, are you trying to send mock notification payload? If so can you try integrating the project with the hotline dashboard and check if the notifications are working?

rsquare2014 commented 8 years ago

Please do reopen if the issue is not fixed.