Last active
October 10, 2018 19:05
-
-
Save flurrydev/de4783dc365b742b62c977c00472ef78 to your computer and use it in GitHub Desktop.
Push - Manual - Registration & Setup - Obj-C
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (BOOL)application:(UIApplication \*)application didFinishLaunchingWithOptions:(NSDictionary \*)launchOptions { | |
// step 1 : register remote notification for ios version >= 10 or < 10 | |
if (@available(iOS 10.0, *)) { | |
NSLog(@"version greater than or equal to 10"); | |
if (@available(iOS 10.0, *)) { | |
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; | |
center.delegate = self; | |
[center requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert) completionHandler:^(BOOL granted, NSError * _Nullable error){ | |
if (!error && granted) { | |
[application registerForRemoteNotifications]; | |
NSLog(@"Push registetration success!"); | |
} else { | |
NSLog(@"Push registration Failed. ERROR : %@ - %@", error.localizedFailureReason, error.localizedDescription); | |
} | |
}]; | |
} | |
} else { | |
NSLog(@"version less than 10"); | |
UIApplication *application = [UIApplication sharedApplication]; | |
if ([application respondsToSelector:@selector(isRegisteredForRemoteNotifications)]) { | |
[application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert) categories:nil]]; | |
[application registerForRemoteNotifications]; | |
} | |
} | |
// step 2 : (Optinoal get a FlurryMessaging Callback) | |
[FlurryMessaging setMessagingDelegate:self]; | |
// step 3 : start flurry session | |
FlurrySessionBuilder* builder = [[[FlurrySessionBuilder alloc] withLogLevel:FlurryLogLevelDebug] withIncludeBackgroundSessionsInMetrics:YES]; | |
[Flurry startSession:@”API_KEY” withOptions:launchOptions withSessionBuilder:builder]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment