AWS PinPoint campaigns not delivered push notifications to iOS - ios

I tried to send push notifications to my iOS and Android physical devices through PinPoint campaigns. Android got it, but not iOS. In exported segment file I see that both my device id's included in segment, but when campaign is finished I see the next:
BTW, Test messaging works on both devices.
Both APNs is enabled:
I'm using React Native, there are hook where I configure Amplify:
export const useConfigureAmplifyNotifications = () => {
useEffect(() => {
Amplify.configure(awsconfig);
PushNotification.configure(awsconfig);
PushNotification.onRegister(token => {
console.log('in app registration: ', token);
PushNotification.updateEndpoint(token);
const endpointId = Analytics.getPluggable('AWSPinpoint')._config.endpointId;
console.log('ENDPOINT ID: ', endpointId);
});
// NativeModules.RNPushNotification.getToken(token => {
// console.log(`PushToken: ${token}`);
// });
PushNotification.onNotification(notification => {
console.log('in app notification', notification);
if (Platform.OS === 'ios') {
notification.finish(PushNotificationIOS.FetchResult.NoData);
}
});
if (Platform.OS === 'ios') {
PushNotification.requestIOSPermissions({
alert: true,
badge: true,
sound: false,
});
}
}, []);
};
My AppDelegate.h file:
#import <React/RCTBridgeDelegate.h>
#import <UIKit/UIKit.h>
#import <UserNotifications/UNUserNotificationCenter.h>
#interface AppDelegate : UIResponder <UIApplicationDelegate, RCTBridgeDelegate,
UNUserNotificationCenterDelegate>
#property (nonatomic, strong) UIWindow *window;
#end
And AppDelegate.m part with notifications:
#import <UserNotifications/UserNotifications.h>
#import <RNCPushNotificationIOS.h>
...
#implementation AppDelegate
// Required for the register event.
- (void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
[RNCPushNotificationIOS didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}
// Required for the notification event. You must call the completion handler after
handling the remote notification.
- (void)application:(UIApplication *)application didReceiveRemoteNotification:
(NSDictionary *)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
[RNCPushNotificationIOS didReceiveRemoteNotification:userInfo
fetchCompletionHandler:completionHandler];
}
// Required for the registrationError event.
- (void)application:(UIApplication *)application
didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
[RNCPushNotificationIOS didFailToRegisterForRemoteNotificationsWithError:error];
}
// Required for localNotification event
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
didReceiveNotificationResponse:(UNNotificationResponse *)response
withCompletionHandler:(void (^)(void))completionHandler
{
[RNCPushNotificationIOS didReceiveNotificationResponse:response];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:
(NSDictionary *)launchOptions
{
...
UNUserNotificationCenter *center = [UNUserNotificationCenter
currentNotificationCenter];
center.delegate = self;
return YES;
}
//Called when a notification is delivered to a foreground app.
-(void)userNotificationCenter:(UNUserNotificationCenter *)center
willPresentNotification:(UNNotification *)notification withCompletionHandler:(void
(^)(UNNotificationPresentationOptions options))completionHandler
{
completionHandler(UNNotificationPresentationOptionSound |
UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionBadge);
}
What I'm doing wrong?

Related

After integrating OneSignal Cordova SDK my App delegate methods are not called for UNUserNotificationCenterDelegate

#import "AppDelegate.h"
#import <UserNotifications/UserNotifications.h>
#import "MainViewController.h"
#interface AppDelegate () <UNUserNotificationCenterDelegate>
#end
#implementation AppDelegate
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
self.viewController = [[MainViewController alloc] init];
[self registerForNotification];
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification*)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler {
// This method are not getting called
completionHandler(UNNotificationPresentationOptionAlert|UNNotificationPresentationOptionBadge|UNNotificationPresentationOptionSound);
}
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(nonnull UNNotificationResponse* )response withCompletionHandler:(nonnull void (^)(void))completionHandler {
// This method are not getting called
NSDictionary *userInfo = response.notification.request.content.userInfo;
completionHandler();
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
NSLog(#"DEVICE_TOKEN :: %#", deviceToken);
const unsigned *tokenBytes = [deviceToken bytes];
NSString *hexToken = [NSString stringWithFormat:#"%08x%08x%08x%08x%08x%08x%08x%08x",
ntohl(tokenBytes[0]), ntohl(tokenBytes[1]), ntohl(tokenBytes[2]),
ntohl(tokenBytes[3]), ntohl(tokenBytes[4]), ntohl(tokenBytes[5]),
ntohl(tokenBytes[6]), ntohl(tokenBytes[7])];
NSString *apnDeviceToken = hexToken;
NSLog(#"APN_DEVICE_TOKEN :: %#", apnDeviceToken);
}
-(void)registerForNotification
{
if(#available(iOS 10.0, *))
{
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
center.delegate = self;
[center requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge) completionHandler:^(BOOL granted, NSError * _Nullable error)
{
if(!error)
{
dispatch_async(dispatch_get_main_queue(), ^ {
[[UIApplication sharedApplication] registerForRemoteNotifications]; // required to get the app to do anything at all about push notifications
NSLog(#"Push registration success." );
});
}
else
{
NSLog(#"Push registration FAILED" );
NSLog(#"ERROR: %# - %#", error.localizedFailureReason, error.localizedDescription );
NSLog(#"SUGGESTIONS: %# - %#", error.localizedRecoveryOptions, error.localizedRecoverySuggestion );
}
}];
}
}
#end
The didReceiveNotificationResponse and willPresentNotification did not trigger. I'm not able to handle Other APNS notification which is not related to one signal Cordova plugin SDK notification.
Is there any way that my app delegate methods for UserNotifications delegate methods will trigger in Cordova ios when one signal plugin used?
I suspect that due to swizzling the app delegate methods by one signal callbacks are not triggered in the original Appdelegate file.
Please help on this if we have any other way to get my app delegate
UserNotifications delegate methods trigger.
As one signal uses the static frameworks in Cordova there is no way to change the code inside the plugin.
This is the one signal plugin for Cordova github https://github.com/OneSignal/OneSignal-Cordova-SDK

Not receiving notification when app in background (iOS react-native)

I am implementing react-native-firebase to one of my projects and trying to add notification feature in it. But i am having problem getting notifications. When i send notification using firebase api "https://fcm.googleapis.com/fcm/send", i get notification when the app is in foreground. But when the app is in background and send the notification, i don't get any. But as soon as i open the app, i receive the notification.
I have already copied the googleservice-info.plist file and uploaded the auth key in firebase.
My main js code :
messagaing.hasPermission()
.then((enabled) => {
if (enabled) {
messagaing.getToken()
.then(async token => {
const deviceId = await AsyncStorage.getItem('deviceId');
if (!deviceId) {
this.registerTokenOnServer(token)
} else {
this.setState({
deviceId
})
}
console.log('fcm token', token)
})
.catch(error => { console.log('fcm error', error) })
} else {
messagaing.requestPermission()
.then(() => { console.log('fcm token') })
.catch(() => { console.log('fcm error') })
}
})
.catch(error => {
console.log('fcm error', error)
})
messagaing.onMessage((message) => {
console.log('fcm noti on message data', message)
let notification_to_be_displayed = new firebase.notifications.Notification({
sound: 'default',
show_in_foreground: true,
title: message._data.title,
body: message._data.message,
});
firebase.notifications().displayNotification(notification_to_be_displayed);
firebase.notifications().onNotificationOpened((notificationOpen) => {
const notification = notificationOpen.notification;
console.log('fcm open ', notification)
if (notification.data.obj_type == '1') {
this.props.navigation.navigate('ProductDetailPage', { prodId: notification.data.obj_id, })
} else {
this.props.navigation.navigate('SubCategoryPage', { catId: notification.data.obj_id, catName: 'Categories' })
}
})
});
My AppDelegate.h :
#import <UserNotifications/UserNotifications.h>
#interface AppDelegate : UIResponder <UIApplicationDelegate, UNUserNotificationCenterDelegate>
#property (nonatomic, strong) UIWindow *window;
#end
My AppDelegate.m :
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#if __has_include(<React/RNSentry.h>)
#import <React/RNSentry.h> // This is used for versions of react >= 0.40
#else
#import "RNSentry.h" // This is used for versions of react < 0.40
#endif
#import "RNGoogleSignin.h"
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <Firebase.h>
#import "RNFirebaseNotifications.h"
#import "RNFirebaseMessaging.h"
#implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSURL *jsCodeLocation;
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:#"index" fallbackResource:nil];
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:#"reactenduser"
initialProperties:nil
launchOptions:launchOptions];
[RNSentry installWithRootView:rootView];
rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
// define UNUserNotificationCenter
[FIRApp configure];
[[UNUserNotificationCenter currentNotificationCenter] setDelegate:self];
[RNFirebaseNotifications configure];
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
[[FBSDKApplicationDelegate sharedInstance] application:application
didFinishLaunchingWithOptions:launchOptions];
return YES;
}
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
return [[FBSDKApplicationDelegate sharedInstance] application:application
openURL:url
sourceApplication:sourceApplication
annotation:annotation
]
|| [RNGoogleSignin application:application
openURL:url
sourceApplication:sourceApplication
annotation:annotation
];
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
[FBSDKAppEvents activateApp];
}
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
[[RNFirebaseNotifications instance] didReceiveLocalNotification:notification];
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo
fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{
[[RNFirebaseNotifications instance] didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings {
[[RNFirebaseMessaging instance] didRegisterUserNotificationSettings:notificationSettings];
}
-(void) userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler {
[[RNFirebaseMessaging instance] didReceiveRemoteNotification:response.notification.request.content.userInfo];
completionHandler();
}
#end
I am not getting any data or error when i send the notification when my app goes to background. Only when it comes in foreground i can see the logs.
Any help would be appreciated. Thank you!
You need to turn on your background capabilities with for remote messages.
check the image
just a note, in my project I have background fetch, I think you can skip it.

Why don't I receive the notification in react native iOS?

So I have problem with notification in IOS, I successfully received the notification in Android but not in IOS. To configure notifications for IOS I followed the documentation of react-native firebase, here are the two links that help me
https://rnfirebase.io/docs/v5.x.x/messaging/ios
https://rnfirebase.io/docs/v5.x.x/notifications/ios
So, here is my configuration
Podfile
AppDelegate.h
`AppDelegate.m``
#import "AppDelegate.h"
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <Firebase.h>
#import "RNFirebaseNotifications.h"
#import "RNFirebaseMessaging.h"
#implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[FIRApp configure];
[RNFirebaseNotifications configure];
NSURL *jsCodeLocation;
...
return YES;
}
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
[[RNFirebaseNotifications instance] didReceiveLocalNotification:notification];
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo
fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{
[[RNFirebaseNotifications instance] didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings {
[[RNFirebaseMessaging instance] didRegisterUserNotificationSettings:notificationSettings];
}
#end
here are the libraries I use
Do you know where I made the wrong configuration to implement notifications for IOS?

Issue subscribing to FCM topic using Xcode/Objective C

I have a problem which I've been unable to resolve. My knowledge of iOS/Xcode is limited, please forgive me.
I am trying to subscribe to an FCM topic for an iOS app using xcode/Objective C but when loading the App, it is not subscribing to the topic, in the debugger it doesn't even look like it is trying.
If I move the [[FIRMessaging messaging] subscribeToTopic:#"/topics/channel"];
line to just below
[FIRMessaging messaging].delegate = self;
[application registerForRemoteNotifications];
[FIRApp configure];
(and above return YES;) then at least I get this error message indicating that it is at least trying.
2018-01-04 04:00:18.723760+0000 App[1049:1251125] [Firebase/Messaging][I-FCM002010] Cannot subscribe to topic: /topics/channel with token: (null)
So following the suggestion here (and a number of other places), I have tried to move it out into didRegisterUserNotificationSettings but it doesn't seem to be doing anything at all and there is no trace of it in the debugger.
This is my full AppDelegate.m code
//
// AppDelegate.m
//
#import "AppDelegate.h"
#import <UserNotifications/UserNotifications.h>
#import <Firebase/Firebase.h>
#import <FirebaseMessaging/FirebaseMessaging.h>
#import <FirebaseInstanceID/FirebaseInstanceID.h>
#import <AFNetworking/AFNetworking.h>
#import Firebase;
#interface AppDelegate () <UNUserNotificationCenterDelegate, FIRMessagingDelegate>
#end
#implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[self setupNetworkReachability];
[UNUserNotificationCenter currentNotificationCenter].delegate = self;
UNAuthorizationOptions authOptions = UNAuthorizationOptionAlert | UNAuthorizationOptionSound | UNAuthorizationOptionBadge;
[[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions:authOptions completionHandler:^(BOOL granted, NSError * _Nullable error)
{
}];
[FIRMessaging messaging].delegate = self;
[application registerForRemoteNotifications];
[FIRApp configure];
//[[FIRMessaging messaging] subscribeToTopic:#"/topics/channel"];
return YES;
}
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UNNotificationSettings *)notificationSettings
{
[[FIRMessaging messaging] subscribeToTopic:#"/topics/channel"];
NSLog(#"Topic Registered");
}
- (void)applicationWillResignActive:(UIApplication *)application
{
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
}
- (void)applicationWillTerminate:(UIApplication *)application
{
}
#pragma mark - Public Methods
+ (AppDelegate *)sharedAppDelegate
{
return (AppDelegate *)[[UIApplication sharedApplication] delegate];
}
- (void)setupNetworkReachability
{
[[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status)
{
if (status == AFNetworkReachabilityStatusReachableViaWiFi || status == AFNetworkReachabilityStatusReachableViaWWAN)
self.isNetworkAvailable = YES;
else
self.isNetworkAvailable = NO;
NSLog(#"Reachability: %#", AFStringFromNetworkReachabilityStatus(status));
}];
[[AFNetworkReachabilityManager sharedManager] startMonitoring];
}
#pragma mark - FIRMessagingDelegate Methods
- (void)messaging:(nonnull FIRMessaging *)messaging didReceiveMessage:(nonnull FIRMessagingRemoteMessage *)remoteMessage
{
NSLog(#"%#", remoteMessage.appData);
}
- (void)applicationReceivedRemoteMessage:(nonnull FIRMessagingRemoteMessage *)remoteMessage
{
NSLog(#"%#", remoteMessage.appData);
}
- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler
{
NSLog(#"%#", notification.request.content.userInfo);
completionHandler(UNNotificationPresentationOptionAlert + UNNotificationPresentationOptionSound);
}
#end
Would appreciate any help. Thank you.
Just to update, the App already receives message directly from FCM console, so that part works OK, it is just the topic subscription that is failing.
1: You should call [FIRApp configure]; before [FIRMessaging messaging].delegate = self;
2: As you post full code of your AppDelegate.m file. So it is missing the below method to update/send token to Firebase. You will receive a TOKEN with in this UIApplication's delegate method and you have to set it for Firebase (Just put this method in your AppDelegate.m file)
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken{
NSString *strDevicetoken = [[NSString alloc]initWithFormat:#"%#",[[[deviceToken description] stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:#"<>"]] stringByReplacingOccurrencesOfString:#" " withString:#""]];
NSLog(#"Device Token = %#",strDevicetoken);
[FIRMessaging messaging].APNSToken = deviceToken;
//NSString *fcmToken = [FIRMessaging messaging].FCMToken;
//NSLog(#"FCM registration token: %#", fcmToken);
}
Now you have successfully set APNS Token at Firebase and you can now subscribe to your desired topic at Firebase

Firebase Phone auth fails to pick up on remote notifications registration

Currently struggling with the following error showing up in logs:
<Error> [Firebase/Auth][I-AUT000015] The UIApplicationDelegate must handle remote notifcation for phone number authentication to work.
as well as this NSError object when calling verifyPhoneNumber:completion: :
#"NSLocalizedDescription" : #"If app delegate swizzling is disabled, remote notifications received by UIApplicationDelegate need to be forwarded to FIRAuth's canHandleNotificaton: method."
#"error_name" : #"ERROR_NOTIFICATION_NOT_FORWARDED"
Anyone know what this is about and how it can be solved?
I am using XCode 8.3.3, Firebase 4.0.0, I've switched OFF swizzling, and I already confirmed that I successfully register both for APNS (I see the token) and for FCM (I see this as well).
I used the sample code both in documentation and in the iOS cloud message github sample repo.
Before trying to integrate Firebase in the same project, I had Digits phone auth working flawlessly, and push notifications coming in both from AWS SNS and OneSignal.
Relevant code for Firebase-related parts:
AppDelegate
+ (void)initialize
{
FIROptions *firOptions = [[FIROptions alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:#"some-plist-name" ofType:#"plist"]];
[FIRApp configureWithOptions:firOptions];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[FIRMessaging messaging].delegate = self;
[FIRMessaging messaging].shouldEstablishDirectChannel = YES;
[UNUserNotificationCenter currentNotificationCenter].delegate = self;
// do some other setup stuff here ...
return YES;
}
#pragma mark - FIRMessagingDelegate
- (void)messaging:(nonnull FIRMessaging *)messaging didRefreshRegistrationToken:(nonnull NSString *)fcmToken {
// I get an fcmToken here as expected and notify the the relevant controller(s)
}
- (void)messaging:(nonnull FIRMessaging *)messaging didReceiveMessage:(nonnull FIRMessagingRemoteMessage *)remoteMessage {
}
#pragma mark - UNUserNotificationCenterDelegate
- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler {
NSDictionary *userInfo = notification.request.content.userInfo;
[[FIRAuth auth] canHandleNotification:userInfo];
completionHandler(UNNotificationPresentationOptionNone);
}
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)())completionHandler {
completionHandler();
}
#pragma mark - Notifications
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken {
FIRMessagingAPNSTokenType tokenType = FIRMessagingAPNSTokenTypeProd;
#if DEBUG && !TESTFLIGHT
tokenType = FIRMessagingAPNSTokenTypeSandbox;
#endif
[[FIRMessaging messaging] setAPNSToken:deviceToken type:tokenType];
}
- (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error {
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
[[FIRAuth auth] canHandleNotification:userInfo];
completionHandler(UIBackgroundFetchResultNewData);
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
[[FIRAuth auth] canHandleNotification:userInfo];
}
- (void)application:(UIApplication *) application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)notification completionHandler:(void (^)())completionHandler {
completionHandler();
}
#end
Controller 1
...
UNAuthorizationOptions authOptions = UNAuthorizationOptionAlert | UNAuthorizationOptionSound | UNAuthorizationOptionBadge;
[[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions:authOptions completionHandler:^(BOOL granted, NSError * _Nullable error) {
}];
[[UIApplication sharedApplication] registerForRemoteNotifications];
...
Controller 2 - after receiving APNS and FCM OK
...
[[FIRPhoneAuthProvider provider] verifyPhoneNumber:#"+11111111"
completion:^(NSString * _Nullable verificationID, NSError * _Nullable error) {
// Here is where I get that error.
}];
...
you have missed to add this method in your AppDelegate
func application(_ application: UIApplication,
didReceiveRemoteNotification notification: [AnyHashable : Any],
fetchCompletionHandler completionHandler: #escaping (UIBackgroundFetchResult) -> Void) {
if Auth.auth().canHandleNotification(notification) {
completionHandler(.noData)
return
}
// This notification is not auth related, developer should handle it.
handleNotification(notification)
}

Resources