davide-scalzo / react-native-mixpanel

A React Native wrapper for Mixpanel tracking
MIT License
455 stars 195 forks source link

Push notification handling data in the app FCM - getInitialNotification - onNotificationOpenedApp #238

Open 0hio-creator opened 4 years ago

0hio-creator commented 4 years ago

I'm using Firebase messaging and would ideally handle the payload with FCM functions.

Messaging.setBackgroundMessageHandler() gets the payload from Mixpanel

But Messaging.getInitialNotification() & Messaging.onNotificationOpenedApp() do not

So FCM can see it when it's in the background but the notification is clicked the data is not passed to JS part of my app.

The code works with FCM generated notifications.

I am receiving Push notifications from Mixpanel and the app opens on click so I'm confident the registration aspect is working.

For Android I have this in my xml // <service // android:name="com.mixpanel.android.mpmetrics.MixpanelFCMMessagingService" // android:enabled="true" // android:exported="false"> // // // //

Has any one been able to access mixpanel push notification data in their js code. Either in IOS or Android? And what Push notification library were you using?

bpfeiffer187 commented 4 years ago

do you have mixpanel profiles set up?

Also just a thought/offer/you and i seem to be having some issues right along similar parts of implmentating this would you be open helping each other out?

0hio-creator commented 4 years ago

Yep and registered devices with Mixpanel so I am receiving push notifications for both IOS and Android. Yeah I'm helping people where I can. Would really appreciate help on this specific issue.

declanelcocks commented 4 years ago
public void onMessageReceived(RemoteMessage remoteMessage) {
        Map message = remoteMessage.getData();

        super.onMessageReceived(remoteMessage);

        if (intercomPushClient.isIntercomPush(message)) {
            Log.d(TAG, "Intercom message received");
            intercomPushClient.handlePush(getApplication(), message);
        } else if (remoteMessage.getData().containsKey("mp_message")) {
            Log.d(TAG, "Mixpanel message received");
            MixpanelFCMMessagingService.showPushNotification(getApplicationContext(), remoteMessage.toIntent());
        }
    }

I have this code and am having the exact same problem. I can see the notification, but in the app firebase is not picking it up via getInitialNotification, onNotificationOpened or onNotification.

@bpfeiffer187 @0hio-creator did you find a solution this?

bpfeiffer187 commented 4 years ago

@declanelcocks @0hio-creator nope i havent. I wouldnt mind jumping on a zoom line with you two and putting our heads together to see if we can figure it out. I would really perfer to get this working without alot of overhead, but right now i am fully setting up firebase and might even just use that short term.

I am on the eastcoast US, let me know if you two want to try that.

abeeralshaer commented 3 years ago

@0hio-creator I have the same problem, notification listener does not handle mixpanel notifications. Did you have any idea how this would work?

mikehlee21 commented 3 years ago

I have exactly the same issue. I can see the push notifications coming for both iOS and Android. But when I tap on the notification, it doesn't trigger the handler. @declanelcocks did you get it working?