mixpanel / mixpanel-iphone

Official iOS (Objective-C) Tracking Library for Mixpanel Analytics
http://mixpanel.com
Apache License 2.0
1.05k stars 564 forks source link

Rich push notifications only works when app is closed #885

Closed lorenc-tomasz closed 3 years ago

lorenc-tomasz commented 4 years ago

Integration Method: CocoaPods Xcode Version: 11.3.1 Library Version: 3.6.0 Platform: iOS and NotificationSerice Language: Objective-C Description: When I send rich notifications with e.g. button that opens the website it works only when app is closed. When app is in foreground or background app gets only Title and body. Expected Behavior: Rich notification should work when app is in foreground and background.

yarikpwnzer commented 4 years ago

For me it's not working at all. When implementing my own NotificationService I am able to receive Rich push notification when directly sending push to APNS with 'mutable-content': 1. With MP implementation by sub-classing NotificationService with MPNotificationServiceExtension I'm only able to receive simple title + body. I'm always using https images.

yarikpwnzer commented 4 years ago

Ok guys after few hours of debugging I found that MP checking image extension inside URL, so you should use images url's like this: https://host.com/some_image.jpg. @lorenc-tomasz for me its also not working in background state. Also I think their image uploader doesn't work well.

yarikpwnzer commented 4 years ago

@lorenc-tomasz off topic (didn't found your email), big thx for fixing alias on react-native-mixpanel, you saved me a lot of time and saved us a lot of money for duplications of thousands people profiles in MP. :) (noticed your PR to that library few minutes ago)

jbwyme commented 4 years ago

Have you perhaps overridden didReceiveRemoteNotification with something that causes a non-rich alert to be shown? Can you share your didReceiveRemoteNotification implementation from your AppDelegate (if you did override it)?

yarikpwnzer commented 4 years ago

@jbwyme

- (void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler {
  [[RNFirebaseNotifications instance] didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
  [RCTPushNotificationManager didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}
stevepetersen commented 4 years ago

I am experiencing this as well, and I think I've found the issue. If you follow the directions and use an empty class that inherits from MPNotificationServiceExtension, the following code is executed, which checks for a userInfo["mp"] key/value pair and returns the original content if it doesn't exists. This means you can't process a rich push from your server.

stevepetersen commented 4 years ago

Here's a workaround: from your server, add the following as the APNS "data" field: {"mp_media_url": link_to_your_image, "mp": {}}. This "tricks" the mixpanel handler into thinking its coming from the mixpanel console.

zihejia commented 3 years ago

Mixpanel is deprecating Messaging and Mobile A/B testing features(more details), please contact our support if you need to continue the conversation for any critical issues. Sorry for the inconvenience.