You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.
We have successfully installed react-native-mixpanel on our project, it works perfectly for sending events and displaying push notifications. We also have FCM push notifications installed and running perfectly for either displaying or handling the push notification payload in this same project.
#import"AppDelegate.h"
#import<React/RCTBridge.h>
#import<React/RCTBundleURLProvider.h>
#import<React/RCTRootView.h>
#import<Firebase.h>
#import"RNSplashScreen.h"
#import<UserNotifications/UserNotifications.h>
#import<RNCPushNotificationIOS.h>
#import<Mixpanel/Mixpanel.h>@implementationAppDelegate
- (BOOL)application:(UIApplication *)applicationdidFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[FIRApp configure];
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:selflaunchOptions:launchOptions];
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
moduleName:@"vega"initialProperties:nil];
rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0fgreen:1.0fblue:1.0falpha:1];
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
[RNSplashScreen show];
[Mixpanel sharedInstance].enableLogging = YES;
UNUserNotificationCenter *center = [UNUserNotificationCentercurrentNotificationCenter];
center.delegate = self;
returnYES;
}
-(void)userNotificationCenter:(UNUserNotificationCenter *)centerwillPresentNotification:(UNNotification *)notificationwithCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler
{
// Only listener called for Mixpanel pushes (apparently used only for displaying)completionHandler(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge);
}
- (void)application:(UIApplication *)applicationdidRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
// Called only for FCM pushes
}
- (void)application:(UIApplication *)applicationdidRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
// Called only for FCM pushes
}
- (void)application:(UIApplication *)applicationdidReceiveRemoteNotification:(NSDictionary *)userInfofetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
// Called only for FCM pushes
}
- (void)application:(UIApplication *)applicationdidFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
// Called only for FCM pushes
}
- (void)userNotificationCenter:(UNUserNotificationCenter *)centerdidReceiveNotificationResponse:(UNNotificationResponse *)responsewithCompletionHandler:(void (^)(void))completionHandler
{
// Called only for FCM pushes
}
- (void)application:(UIApplication *)applicationdidReceiveLocalNotification:(UILocalNotification *)notification
{
// Called only for FCM pushes
}
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"fallbackResource:nil];
#elsereturn [[NSBundlemainBundle] URLForResource:@"main"withExtension:@"jsbundle"];
#endif
}
@end
Issue
We need to be able to catch and read the Mixpanel notification payload when the app is either on foreground, background or closed. But apparently none of the iOS listeners catch the notification payload UNLESS we tap on it. So the notification is just displayed on device screen and that is all. On the other hand, the listeners work perfectly with our FCM push notifications WITHOUT needing to tap on them.
Below are the automatically generated Xcode logs we get when enabling [Mixpanel sharedInstance].enableLogging = YES;:
When receiving FCM push notification either on Foreground or Background (without needing to tap on it):
Just discovered that adding a custom JSON for iOS (while creating the notification on Mixpanel Messages panel) like this solves this issue:
it's important to mention that we should not add commas at the end of the last value like we normally do in javascript. If we add that little comma Mixpanel will silently ignore the custom JSON content.
The app now successfully reacts to the push notification whenever it's running on Foreground or Background. But I still don't know how to make things work if the app is quit (not running).
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Context
We have successfully installed
react-native-mixpanel
on our project, it works perfectly for sending events and displaying push notifications. We also have FCM push notifications installed and running perfectly for either displaying or handling the push notification payload in this same project.We are using the versions below:
This is how our AppDelegate is looking with all its push notification listeners:
Issue
We need to be able to catch and read the Mixpanel notification payload when the app is either on foreground, background or closed. But apparently none of the iOS listeners catch the notification payload UNLESS we tap on it. So the notification is just displayed on device screen and that is all. On the other hand, the listeners work perfectly with our FCM push notifications WITHOUT needing to tap on them.
Below are the automatically generated Xcode logs we get when enabling
[Mixpanel sharedInstance].enableLogging = YES;
:Proposed solution
Looks like Mixpanel push notifications only allows for notification displaying, which means it probably does not contain the latest APNS headers that need to be sent to the device in order for the device to receive the payload. You can check Apple Documentation here: https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/sending_notification_requests_to_apns/
We had similar issue with FCM payload, and we solved it by using the block below including the
contentAvailable
and the correctapns-headers
:Could you please advise or update the notification payload to support the latest iOS?
Thanks!
The text was updated successfully, but these errors were encountered: