react-native-zendesk-chat icon indicating copy to clipboard operation
react-native-zendesk-chat copied to clipboard

Firebase messaging on Android

Open jamie78 opened this issue 3 years ago • 11 comments

Hello everybody. First of all thx for the library. I'm using it on 2 projects right now. Anyway, I have a question. I'm able to get the push notifications on both platforms.

On android I'm not able to receive push notification once the app is killed.

// listen on foreground  ==> working
messaging().onMessage(async remoteMessage => {
}

// listen on background + quit state ==> working if app is in background, not working if app is killed
messaging().setBackgroundMessageHandler(async remoteMessage => {
}

Also one interesting note: On Android I'm not able to receive a push notifications. I'm able to listen on those functions but no push notification is called.

Do you have an idea? Am I missing some config? I found this one. https://developer.zendesk.com/embeddables/docs/chat-sdk-v-2-for-android/push_notifications Do I need to change the firebase method as well?

class MyFirebaseMessagingService extends FirebaseMessagingService {

    @Override
    onMessageReceived(RemoteMessage remoteMessage) {
    super.onMessageReceived(remoteMessage);

    PushData pushData = pushNotificationsProvider.processPushNotification(remoteMessage);
}

Thx

jamie78 avatar Feb 16 '21 15:02 jamie78

This is either an upstream issue in ZendeskChat Android, or it’s an issue with push notifications in general in your app, which unfortunately, in either case, I can’t really provide support there.

As I’m a volunteer, and we don’t use the Zendesk push notification option, I recommend you reach out to Zendesk’s customer support desk!

fbartho avatar Feb 16 '21 17:02 fbartho

iOS is working fine for me. Notifications are coming. Android notifications are coming too, but just the data. No real push notification. For now I was able to trigger notification with LocalNotification. As you may know, once app is killed you are not able to trigger anything. It's on system level. Firebase server key is connected to zen desk. In my opinion there is something wrong with zen desk firebase integration.

jamie78 avatar Feb 16 '21 17:02 jamie78

@fbartho do you know if you are able to show unread messages for user?

jamie78 avatar Feb 16 '21 17:02 jamie78

Update: in my opinion you need to somehow fire the notification, not sure if firebase is missing something.

class MyFirebaseMessagingService extends FirebaseMessagingService {

    @Override
    onMessageReceived(RemoteMessage remoteMessage) {
    Log.d(TAG, "fire each time on notification");
    super.onMessageReceived(remoteMessage);
}

Each time I will send a message from zendesk (even when app is killed), the log is called. So definitely something is missing.

As Android is using firebase messaging for it, it would probably require to do some change.

jamie78 avatar Feb 16 '21 19:02 jamie78

@jamie78 Android has the concept of Data-only notifications as well as Visible notifications. -- Is it possible Zendesk's backend is sending "data-only" notifications?

You should not have to have any code running to get visible notifications to display!

fbartho avatar Feb 16 '21 23:02 fbartho

@jamie78 Are you at paid plan or using trial version of chat? It sends data-only on trial version.

ArtemVass avatar Feb 17 '21 08:02 ArtemVass

@ArtemVass I'm on trial, but still should be used for 14 days the Professional plan.

jamie78 avatar Feb 17 '21 08:02 jamie78

@jamie78 I talked to Zendesk support recently: notifications are fully enabled at paid plan only. On paid everything works like magic.

ArtemVass avatar Feb 17 '21 08:02 ArtemVass

@ArtemVass thx for the info. I will try. but here: https://support.zendesk.com/hc/en-us/articles/360022365313-Enabling-push-notifications-in-the-Chat-SDK-for-mobile-apps

From zendesk support:

Hi Maulik Pandya! I'm not aware of any limitations for trialers, however there could be some things specific to your account
that would prevent this from working properly. I would recommend reaching out to our Advocacy team from within your
instance (Help widget on the right side) and they will be able to see if there are any limitations for you!

jamie78 avatar Feb 17 '21 08:02 jamie78

@jamie78 To my experience, Zendesk support is pretty, ehm, confusing. This is what they said to me:

Apologies about this, but that is correct, paid plans are required for both IOS and Android, see below,

https://developer.zendesk.com/chat-sdk-v-2-for-android_delete/docs/android-chat-sdk/push_notifications ​ https://developer.zendesk.com/chat-sdk-v-2-for-android_delete/docs/ios-chat-sdk/push_notifications ​

ArtemVass avatar Feb 17 '21 08:02 ArtemVass

@ArtemVass I think you are probably right. Notification from zendesk:

{"data": {"data": "{\"author\":\"Jakub Kraus\",\"message\":\"sdsdsd\",\"type\":\"zd.chat.msg\",\"ts\":1613552261}"}, "from": "341409816227", "messageId": "0:1613552261649404%1596f81ef9fd7ecd", "sentTime": 1613552261633, "ttl": 2419200}

Test notification from Firebase:

 {"collapseKey": "xxxx", "data": {}, "from": "341409816227", "messageId": "0:1613553638791016%1596f81e1596f81e", "notification": {"android": {}, "body": "sdsdssdsd", "title": "dssdsdsd"}, "sentTime": 0, "ttl": 2419200}

So notification part is missing :D. :D :D

jamie78 avatar Feb 17 '21 09:02 jamie78