Open tjhowe opened 5 years ago
@tjhowe I am currently trying to implement the exact same thing for Android.
I am receiving/seeing the push notifications in Android (regardless of whether the app is open or closed). I am just not seeing any events happening in the JS from Firebase.
android/app/src/main/java/com/app/PushProvidersHandler.java
package com.app;
import io.invertase.firebase.messaging.RNFirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
import com.mixpanel.android.mpmetrics.MixpanelFCMMessagingService;
import android.util.Log;
public class PushProvidersHandler extends RNFirebaseMessagingService {
private static final String TAG = "PushProviderService";
@Override
public void onNewToken(String s) {
super.onNewToken(s);
MixpanelFCMMessagingService.addToken(s);
}
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
if (remoteMessage.getData().containsKey("mp_message")) {
MixpanelFCMMessagingService.showPushNotification(getApplicationContext(), remoteMessage.toIntent());
}
}
}
android/app/src/main/AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.app">
...
<application ...>
<meta-data android:name="com.mixpanel.android.MPConfig.NotificationChannelId"
android:value="app-notifications" />
<meta-data android:name="com.mixpanel.android.MPConfig.NotificationChannelName"
android:value="App Notifications" />
<meta-data android:name="com.mixpanel.android.MPConfig.NotificationChannelImportance"
android:value="4" />
<service android:name=".PushProvidersHandler" android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
...
</application>
</manifest>
Have you made any progress?
@tjhowe @craigcoles did you ever solve this one?
@declanelcocks Unfortunately, I never got much further than what I posted before. The problem I found is the payload of the notification. Mixpanel sends a very custom payload which makes things trickier.
@craigcoles yeah...I can never get Firebase to pick up the notification in the app, it's a pain as I can see the payload is there too when debugging the Java side.
I've been implementing adding mixpanel to a project with an existing firebase configuration. I've followed the installation documentation outline in the readme. Then I added the extension of the FirebaseMessagingService outline in this release. I am also using firebase notifications in the react native app, I receive iOS notifications in the js listeners, but not android.
I then added this service to my Manifest file.
I am receiving the notification data from mixpanel when logging in logcat in android studio, so i assume the api keys are provided - however I only receive background notifications. The MixpanelFCMMessagingService.showPushNotification is being called, so I'm not 100 percent sure where I'm going wrong!