Я добавил категорию к моему расширению info.plist. Также передача той же категории в полезной нагрузке. Добавлено расширение службы уведомлений для проекта response-native iOS native.
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>
идентификатор пакета расширения: -
myprojectbundleid.extension
Код расширения: -
# 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
полезная нагрузка
{
"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"
}
}
Любые предложения будут полезны.