Skip to content

Instantly share code, notes, and snippets.

@saurabh23july
Created November 28, 2015 07:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saurabh23july/d419135f199be305bebf to your computer and use it in GitHub Desktop.
Save saurabh23july/d419135f199be305bebf to your computer and use it in GitHub Desktop.
- (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