diff --git a/Sources/Earthquake Network/AppDelegate.m b/Sources/Earthquake Network/AppDelegate.m index 30b96eb..b3e8043 100644 --- a/Sources/Earthquake Network/AppDelegate.m +++ b/Sources/Earthquake Network/AppDelegate.m @@ -19,9 +19,9 @@ #import "EQNNotificheReteSismiche.h" #import "EQNMainTabBarController.h" +@import UserNotifications; @import Firebase; @import FirebaseCrashlytics; -@import UserNotifications; @import GoogleMobileAds; @import FBSDKCoreKit; @@ -59,13 +59,7 @@ NSString *language = [[NSLocale preferredLanguages] firstObject]; [[FIRCrashlytics crashlytics] setCustomValue:language forKey:@"lang"]; - [UNUserNotificationCenter currentNotificationCenter].delegate = self; - UNAuthorizationOptions authOptions = UNAuthorizationOptionAlert | UNAuthorizationOptionSound | UNAuthorizationOptionBadge; - [[UNUserNotificationCenter currentNotificationCenter] - requestAuthorizationWithOptions:authOptions - completionHandler:^(BOOL granted, NSError * _Nullable error) { - [self registraNotifica]; - }]; + [self configurePushNotifications]; [application setMinimumBackgroundFetchInterval:UIApplicationBackgroundFetchIntervalMinimum]; [application registerForRemoteNotifications]; @@ -199,6 +193,17 @@ [self.mainTabBarController selectSection:section]; } +#pragma mark - Configurations + +- (void)configurePushNotifications +{ + [UNUserNotificationCenter currentNotificationCenter].delegate = self; + UNAuthorizationOptions authOptions = UNAuthorizationOptionAlert | UNAuthorizationOptionSound | UNAuthorizationOptionBadge; + [[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions:authOptions completionHandler:^(BOOL granted, NSError * _Nullable error) { + [self registraNotifica]; + }]; +} + #pragma mark - FIRMessagingDelegate - (void)messaging:(FIRMessaging *)messaging didReceiveRegistrationToken:(NSString *)fcmToken