Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16552

Notification service extensions not working for iOS with react-native-firebase

$
0
0

I have added the category to my extension info.plist. Also passing the same category in the payload.Added Notification Service extension to react-native project iOS native side.

Extension Plist :-

<key>NSExtension</key><dict><key>NSExtensionAttributes</key><dict><key>UNNotificationExtensionCategory</key><string>ACTION_BUTTON</string></dict><key>NSExtensionPointIdentifier</key><string>com.apple.usernotifications.service</string><key>NSExtensionPrincipalClass</key><string>$(PRODUCT_MODULE_NAME).NotificationService</string></dict>

extension bundle id :-

myprojectbundleid.extension

Extension code:-

#import "NotificationService.h"#import "RNFirebaseMessaging.h"

@interface NotificationService ()

@property (nonatomic, strong) void (^contentHandler)(UNNotificationContent *contentToDeliver);@property (nonatomic, strong) UNMutableNotificationContent *bestAttemptContent;@end@implementation NotificationService- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:   (void (^)(UNNotificationContent * _Nonnull))contentHandler {  NSLog(@"=======NotificationService");    self.contentHandler = contentHandler;    self.bestAttemptContent = [request.content mutableCopy];    // Modify the notification content here...    self.bestAttemptContent.title = @"modified title";   [[FIRMessaging extensionHelper] populateNotificationContent:self.bestAttemptContent withContentHandler:contentHandler];      self.contentHandler(self.bestAttemptContent);}- (void)serviceExtensionTimeWillExpire {   // Called just before the extension will be terminated by the system.   // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.    self.contentHandler(self.bestAttemptContent);}@end

payload

{"mutable-content" : 1,"notification": { "title":"Take score","body": "Take your score","sound": "default","click_action":"ACTION_BUTTON","mutable_content": 1   },"apns":{"payload": {"aps": {"mutable-content": 1,"click_action": "ACTION_BUTTON","category": "ACTION_BUTTON"         }       }    },  "to":"tokentosend","data":{ "channel_id": "channel_id","title":"You have a new message12","body": "hi","sound": "default"      } }

Any suggestions would be helpful.


Viewing all articles
Browse latest Browse all 16552

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>