iOS Notification Service Extension not getting called
See original GitHub issueHere’s the payload I’m sending from the Firebase Admin SDK (Python)
messaging.Message(
notification=messaging.Notification(
body=data_message['body'],
title=data_message['title'],
),
apns=messaging.APNSConfig(
payload=messaging.APNSPayload(aps=messaging.Aps(mutable_content=1, content_available=1, sound= "ting.wav"),
notifee_options={
'ios': {
'critical': True,
'sound': "ting.wav",
'criticalVolume': 0.2,
'categoryId': "channelHigh",
},
'data': data_message
}
),
),
token=registration_token[args.device],
)
Here’s my NotificationService.m (To debug, I’ve tried to modify the title of bestAttemptContent before sending it to the NotifeeExtensionHelper)
#import "NotificationService.h"
#import "NotifeeExtensionHelper.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 {
self.contentHandler = contentHandler;
self.bestAttemptContent = [request.content mutableCopy];
self.bestAttemptContent.title = [NSString stringWithFormat:@"%@ [SE]", self.bestAttemptContent.title];
[NotifeeExtensionHelper populateNotificationContent:request
withContent: self.bestAttemptContent
withContentHandler:contentHandler];
}
- (void)serviceExtensionTimeWillExpire {used.
self.contentHandler(self.bestAttemptContent);
}
@end
In foreground, notification is handled by RNFirebase’s onMessage() function. However, in the background or in quit state it just delivers the notification as-is, with no modifications. It doesn’t even change the title, which leads me to believe that the NSE isn’t getting called at all. Moreover, the setBackgroundMessageHandler isn’t taking effect either.
The only relevant logs I get from Xcode are:
[RNFBMessagingModule signalBackgroundMessageHandlerSet] [Line 95] signalBackgroundMessageHandlerSet called
[RNFBMessagingAppDelegate signalBackgroundMessageHandlerSet] [Line 74] signalBackgroundMessageHandlerSet sharedInstance.backgroundMessageHandlerSet was NO
but I’m very clearly setting the backgroundMessageHandler in my entry-level index.js:
import messaging from "@react-native-firebase/messaging";
import notificationHandler from './notificationHandler'
messaging().onMessage(notificationHandler);
messaging().setBackgroundMessageHandler(notificationHandler);
Any leads on what could be wrong?
Edit: I upgraded from 4.0.0 to 4.1.0 and RNFirebase from 13 to 14, but background notifications didn’t work previously either.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (3 by maintainers)
Top Related StackOverflow Question
I think there is an edit link on each docs page maybe this could be a note on the extension doc, as a PR?
In my case the actual notification service extension (NSE) was not firing because of a mismatch of ios targets between the main app and NSE.