Skip to content

Instantly share code, notes, and snippets.

Created November 28, 2015 07:21
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
- (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