Created
November 28, 2015 07:21
-
-
Save saurabh23july/d419135f199be305bebf to your computer and use it in GitHub Desktop.
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 { | |
// Override point for customization after application launch | |
// Let the device know we want to receive push notifications | |
if ([application respondsToSelector:@selector(isRegisteredForRemoteNotifications)]) | |
{ | |
// for iOS 8 | |
[application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]]; | |
[application registerForRemoteNotifications]; | |
} | |
application.applicationIconBadgeNumber = 0; | |
// Register for Push notifictions . It will ask to recieve push notifactions when the app starts . | |
return YES; | |
} | |
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken | |
{ | |
NSLog(@"My token is: %@", deviceToken); | |
} | |
// Send this device token to recieve Push notifications | |
- (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error | |
{ | |
NSLog(@"Failed to get token, error: %@", error); | |
} | |
// Shows error if Push notifactions can`t be sent . This method will display error . | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment