Closed SMJ93 closed 4 years ago
Hey,
I'm using the following to register the token with mixpanel.
for ios
let token = await messaging().getAPNSToken()
Mixpanel.addPushDeviceToken(token)
Not using any native code
const authStatus = await messaging().requestPermission();
Using firebase messaging to handle responese
export const backgroundHandler = async () => {
messaging().setBackgroundMessageHandler(async remoteMessage => {
console.log('Message handled in the background!', remoteMessage);
});
}
Hi @0hio-creator, what about calling addPushDeviceToken
in the AppDelegate.m?
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
Mixpanel *mixpanel = [Mixpanel sharedInstance];
[mixpanel.people addPushDeviceToken:deviceToken];
}
Don't you need to do this?
@SMJ93
Mixpanel.addPushDeviceToken(token)
does the same thing but slightly different usage.
The delegate sets a callback to send the apns token whenever didRegisterForRemoteNotificationsWithDeviceToken is called.
Where as Mixpanel.addPushDeviceToken(token)
is called where you choose to run it.
messaging().requestPermission()
Is the firebase call for registering for remote notifications. So i did ~something like this
var authStatus = await messaging().requestPermission()
// check user has given permission
if (authStatus == 1 || authStatus ==2) {
let token = await messaging().getAPNSToken()
Mixpanel.addPushDeviceToken(token)
}
After i register for notifications.
Another thing to note is that you need to have called Mixpanel.identify
somewhere before either Mixpanel.addPushDeviceToken or the delegate.m code is called.
Particularly watch for the case of an app reinstall
Thanks @0hio-creator !
Have anyone had problem on receiving mixpanel push notification on Foreground (app is visible to the user) using the react-native-firebase?
Currently I am not able to receive it on foreground (on iOS), but I receive it on background and I did not add any Mixpanel native configuration and I am calling the Mixpanel.identify
and sending the APN token through Mixpanel.addPushDeviceToken(token)
It used to work fine with firebase v5, but since upgrading I don't receive any notifications.
Here is my code:
JS:
AppDelegate.m