Skip to content

Instantly share code, notes, and snippets.

@bithavoc
Created December 4, 2014 22:12
Show Gist options
  • Save bithavoc/e7a4c756dc6b085e8913 to your computer and use it in GitHub Desktop.
Save bithavoc/e7a4c756dc6b085e8913 to your computer and use it in GitHub Desktop.
//
// AppDelegate.m
// testNotifications
//
// Created by Johan Ride on 12/4/14.
// Copyright (c) 2014 Ride.com. All rights reserved.
//
#import "AppDelegate.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
UIUserNotificationType types = UIUserNotificationTypeBadge |
UIUserNotificationTypeSound | UIUserNotificationTypeAlert;
UIUserNotificationSettings *mySettings =
[UIUserNotificationSettings settingsForTypes:types categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:mySettings];
[application registerForRemoteNotifications];
// Override point for customization after application launch.
return YES;
}
// if registration succeeds
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)devToken {
NSLog(@"Device token is: %@", [NSString stringWithFormat:@"%@", devToken]);
}
// if registration fails
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error NS_AVAILABLE_IOS(3_0) {
NSLog(@"Failed to register for remote notifications with error: %@", error);
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment