[iOS] Push Notification not showing in background/quit state
Closed this issue · 2 comments
Describe the bug
I think i configured well the sdk.
I turned the entitlements to production, I set the .p12 in the zendesk admin center platform. What I am doing wrong? I am testing it in the production environment of the app.
Thanks for your help.
Expected behavior
Showing push notifications in background/quit states when I receive a message from the chat In App.
AppDelegate.h
#import <RCTAppDelegate.h>
#import <UIKit/UIKit.h>
#import <UserNotifications/UserNotifications.h>
@interface AppDelegate : RCTAppDelegate <UIApplicationDelegate, RCTBridgeDelegate, UNUserNotificationCenterDelegate>
@end
AppDeletage.m
#import <Firebase.h>
#import <React/RCTBundleURLProvider.h>
#import "RNSplashScreen.h"
#import <CodePush/CodePush.h>
#import <UserNotifications/UserNotifications.h>
#import <ZendeskNativeModule.h>
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[FIRApp configure];
bool didFinish=[super application:application didFinishLaunchingWithOptions:launchOptions];
[RNSplashScreen show];
[self registerForPushNotifications];
return didFinish;
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
[ZendeskNativeModule updatePushNotificationToken:deviceToken];
}
// (1. Show push notifications)
// ZendeskNativeModule.showNotification
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
willPresentNotification:(UNNotification *)notification
withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler {
id userInfo = notification.request.content.userInfo;
BOOL isHandled = [ZendeskNativeModule showNotification:userInfo completionHandler:completionHandler];
if (isHandled) return;
// other handing code here
// If not handled, you should call the `completionHandler` before end of `userNotificationCenter` method
completionHandler(UNNotificationPresentationOptionNone);
}
// (2. Handle tap notifications)
// ZendeskNativeModule.handleNotification
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
didReceiveNotificationResponse:(UNNotificationResponse *)response
withCompletionHandler:(void (^)(void))completionHandler {
id userInfo = response.notification.request.content.userInfo;
BOOL isHandled = [ZendeskNativeModule handleNotification:userInfo completionHandler:completionHandler];
if (isHandled) return;
// other handing code here
// If not handled, you should call the `completionHandler` before end of `userNotificationCenter` method
completionHandler();
}
- (void)registerForPushNotifications {
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
center.delegate = self;
[center requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge)
completionHandler:^(BOOL allowed, NSError * _Nullable error) {
if (allowed) {
dispatch_async(dispatch_get_main_queue(), ^{
[[UIApplication sharedApplication] registerForRemoteNotifications];
});
}
}];
}
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
#else
return [CodePush bundleURL];
#endif
}
@end
Environment (please complete the following information):
- iOS
- React Native Version 0.72.4
- react-native-zendesk-messaging Version 0.2.1
I have the same problem. It works on Android, but on iOS I do not receive any push notification from Zendesk
I have the same problem. It works on Android, but on iOS I do not receive any push notification from Zendesk
Can I ask you if you have tested in testflight?
Edit:
Tested in testflight works as spected.