Closed bohrend closed 4 years ago
Hi @bohrend, Apologies for the delayed response.
You will need to implement your notification listener in native code to achieve silent push functionality for iOS on React Native. This is an iOS platform restriction, as iOS does not support React Native's headless JS feature.
Add the following lines to your ios/app/AppDelegate.m
file, anywhere inside your app's didFinishLaunchingWithOptions
method:
// Handle silent push notifications
[pushy setNotificationHandler:^(NSDictionary *data, void (^completionHandler)(UIBackgroundFetchResult)) {
// Print notification payload data
NSLog(@"Received notification: %@", data);
// Custom logic...
// You must call this completion handler when you finish processing
// the notification (after fetching background data, if applicable)
completionHandler(UIBackgroundFetchResultNewData);
}];
Please add the required import statement:
#import <Pushy/Pushy-Swift.h>
Make sure to delete the notification listener defined in your RN JS app (Pushy.setNotificationListener()
), and enable the Background Modes -> Remote Notifications capability in your Xcode project settings.
Hi, I have logic in my notificationListener that I want fired, it doesn't have to show the notification in notification panel (so basically a silent push). Its a react native app, I understand ios notifications don't show when the app is in the foreground, but I came across this in the pushy documentation:
Should this enabled the logic in notificationListener to fire? if not, could you recommend or guide me in the right direction, thanks!