Closed olehmartynets closed 2 years ago
push notification from intercom work fine on Android 6, but doesn't work on Android 9
my code:
package com.jajaapp; import io.invertase.firebase.messaging.*; import android.content.Intent; import android.content.Context; import io.intercom.android.sdk.push.IntercomPushClient; import io.invertase.firebase.messaging.RNFirebaseMessagingService; import com.google.firebase.messaging.RemoteMessage; import android.util.Log; import java.util.Map;
public class MainMessagingService extends RNFirebaseMessagingService { private static final String TAG = "MainMessagingService"; private final IntercomPushClient intercomPushClient = new IntercomPushClient();
@Override public void onMessageReceived(RemoteMessage remoteMessage) { Map message = remoteMessage.getData(); if (intercomPushClient.isIntercomPush(message)) { Log.d(TAG, "Intercom message received" + message.toString()); intercomPushClient.handlePush(getApplication(), message); } else { super.onMessageReceived(remoteMessage); } }
}
export const getToken = () => pushNotifications.getToken().then(fcmToken => { if (fcmToken) { console.log('token ', fcmToken) Intercom.sendTokenToIntercom(fcmToken) return sendToken(fcmToken) .catch(() => logger.error('Error while saving token')) } else { logger.error('Error while GETTING token') } })
export const getNotificationListener = () => firebase.notifications().onNotification(notification => { console.log('push ', notification) const channel = new firebase.notifications.Android.Channel( 'LOCAL_NOTIFICATION', 'Notification', firebase.notifications.Android.Importance.Max ).setDescription('A natural description of the channel') firebase.notifications().android.createChannel(channel) const localNotification = new firebase.notifications.Notification({show_in_foreground: true}) .setBody(notification.body) .setNotificationId(notification.notificationId) .setData(notification.data) .setTitle(notification.title) .setSound('default') .android.setChannelId('LOCAL_NOTIFICATION') .android.setSmallIcon('ic_push_notification') firebase.notifications().displayNotification(localNotification)
handleTransactionUpdate()
})
Seeing the same thing
push notification from intercom work fine on Android 6, but doesn't work on Android 9
my code:
package com.jajaapp; import io.invertase.firebase.messaging.*; import android.content.Intent; import android.content.Context; import io.intercom.android.sdk.push.IntercomPushClient; import io.invertase.firebase.messaging.RNFirebaseMessagingService; import com.google.firebase.messaging.RemoteMessage; import android.util.Log; import java.util.Map;
public class MainMessagingService extends RNFirebaseMessagingService { private static final String TAG = "MainMessagingService"; private final IntercomPushClient intercomPushClient = new IntercomPushClient();
}
export const getToken = () => pushNotifications.getToken().then(fcmToken => { if (fcmToken) { console.log('token ', fcmToken) Intercom.sendTokenToIntercom(fcmToken) return sendToken(fcmToken) .catch(() => logger.error('Error while saving token')) } else { logger.error('Error while GETTING token') } })
export const getNotificationListener = () => firebase.notifications().onNotification(notification => { console.log('push ', notification) const channel = new firebase.notifications.Android.Channel( 'LOCAL_NOTIFICATION', 'Notification', firebase.notifications.Android.Importance.Max ).setDescription('A natural description of the channel') firebase.notifications().android.createChannel(channel) const localNotification = new firebase.notifications.Notification({show_in_foreground: true}) .setBody(notification.body) .setNotificationId(notification.notificationId) .setData(notification.data) .setTitle(notification.title) .setSound('default') .android.setChannelId('LOCAL_NOTIFICATION') .android.setSmallIcon('ic_push_notification') firebase.notifications().displayNotification(localNotification)
})