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
I have a notification extension service integrated, and I am successfully receiving notifications in all three states: foreground, background, and killed. When I click on a notification in the foreground, the onForegroundEvent is triggered as expected. However, in the other two states (background and killed), this is not working. While didReceiveNotificationRequest works, setBackgroundMessageHandler is not functioning on iOS. I believe this might be the intended behavior of iOS, as the app is not supposed to work in the background state, but i am confused why onForegroundEvent is not working on clicking on background notifications. (I know onBackgroundEvent is not supposed to work in iOS)
//// NotificationService.m// NotificationServiceExtension//////
#import"NotificationService.h"
#import"NotifeeExtensionHelper.h"@interfaceNotificationService ()
@property (nonatomic, strong) void (^contentHandler)(UNNotificationContent *contentToDeliver);
@property (nonatomic, strong) UNMutableNotificationContent *bestAttemptContent;
@end@implementationNotificationService
- (void)didReceiveNotificationRequest:(UNNotificationRequest *)requestwithContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
self.contentHandler = contentHandler;
self.bestAttemptContent = [request.content mutableCopy];
// Modify the notification content here...NSLog(@"Sample Message");
[NotifeeExtensionHelper populateNotificationContent:request
withContent:self.bestAttemptContent
withContentHandler:contentHandler];
}
- (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
I have a notification extension service integrated, and I am successfully receiving notifications in all three states: foreground, background, and killed. When I click on a notification in the foreground, the
onForegroundEvent
is triggered as expected. However, in the other two states (background and killed), this is not working. WhiledidReceiveNotificationRequest
works,setBackgroundMessageHandler
is not functioning on iOS. I believe this might be the intended behavior of iOS, as the app is not supposed to work in the background state, but i am confused whyonForegroundEvent
is not working on clicking on background notifications. (I knowonBackgroundEvent
is not supposed to work in iOS)Postman Request :
NotificationService.m :
index.js :
Environment :
The text was updated successfully, but these errors were encountered: