Closed hungkoala closed 3 years ago
exactly these lines cause issue
// UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
// [center requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge) completionHandler:^(BOOL granted, NSError * _Nullable error) {
// center.delegate = self;
// if (granted){
// // dispatch_async(dispatch_get_main_queue(), ^{
// // UNNotificationCategoryOptions categoryOptions = UNNotificationCategoryOptionNone;
// // UNTextInputNotificationAction *reply = [UNTextInputNotificationAction actionWithIdentifier:@"Reply" title:@"Reply" options:@[] textInputButtonTitle:@"Send" textInputPlaceholder:@"Message"];
// // UNNotificationCategory *chatGrpMsgCategory_10 = [UNNotificationCategory categoryWithIdentifier:@"GRPCHATMSG" actions:@[reply] intentIdentifiers:@[] options:categoryOptions];
// // [[UNUserNotificationCenter currentNotificationCenter] setNotificationCategories:[NSSet setWithObjects:chatGrpMsgCategory_10,chatGrpMsgCategory_10, nil]];
// // [application registerForRemoteNotifications];
// // });
// }
// }];
exactly these lines cause issue
// UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; // [center requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge) completionHandler:^(BOOL granted, NSError * _Nullable error) { // center.delegate = self; // if (granted){ // // dispatch_async(dispatch_get_main_queue(), ^{ // // UNNotificationCategoryOptions categoryOptions = UNNotificationCategoryOptionNone; // // UNTextInputNotificationAction *reply = [UNTextInputNotificationAction actionWithIdentifier:@"Reply" title:@"Reply" options:@[] textInputButtonTitle:@"Send" textInputPlaceholder:@"Message"]; // // UNNotificationCategory *chatGrpMsgCategory_10 = [UNNotificationCategory categoryWithIdentifier:@"GRPCHATMSG" actions:@[reply] intentIdentifiers:@[] options:categoryOptions]; // // [[UNUserNotificationCenter currentNotificationCenter] setNotificationCategories:[NSSet setWithObjects:chatGrpMsgCategory_10,chatGrpMsgCategory_10, nil]]; // // [application registerForRemoteNotifications]; // // }); // } // }];
The above snippet of code is just responsible for registering the application for remote notifications and is not directly related to SalesIQ Mobilisten. This step is required to receive the token used for remote notifications.
We see that Firebase is being used in the application and as per the firebase documentation, it is required to register the application for remote notification as done in the above snippet. Do you happen to be registering the application for remote notifications elsewhere and do remote notifications work for you without these lines?
Hi, It'a react-native app and I followed this guideline https://rnfirebase.io/messaging/usage
Currently at foreground mode, if i turn off the register lines above, Notifee will show notification popups. If if I enable register code, application will show nothing
It is likely that UNUserNotificationCenter's delegate property is being set by Notifee elsewhere.
Could you try commenting out the center.delegate = self;
line alone and see if it everything works?
If yes, could you try adding the below code to application(_:didFinishLaunchingWithOptions:)
method as the first line and then try running the application?
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
center.delegate = self;
To add, you can use the RNZohoSalesIQ.isMobilistenNotification
method to check if the notification is intended to be handled by Mobilisten by passing the notification content, else the notification would need to be handled by Notifee.
The function requestAuthorizationWithOptions
override permission required by Notifee notifee.requestPermission()
see requestpermission that causes the issue. If the line // [center requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge) completionHandler:^(BOOL granted, NSError * _Nullable error) {
is removed, application will work well
SalesIQ blocks notifee to show notifications. If I remove all SalesIQ code in AppDelegate.m the application works well
Here is the code