Skip to content

Instantly share code, notes, and snippets.

@markbates
Created July 25, 2009 20:33
Show Gist options
  • Save markbates/154957 to your computer and use it in GitHub Desktop.
Save markbates/154957 to your computer and use it in GitHub Desktop.
- (void)applicationDidFinishLaunching:(UIApplication *)application {
[window addSubview:[navigationController view]];
[window makeKeyAndVisible];
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
}
// Delegation methods
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)devToken {
Device *device = [[Device alloc] init];
device.token = [devToken description];
[device saveRemote];
if ([device getRemoteId] != nil) {
NSLog(@"success!");
}
}
- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err {
NSLog(@"Error in registration. Error: %@", err);
}
@igoodrich
Copy link

minor thing: you're leaking the device in the second method. No?
In general -- thanks for the great work on Objective Resource!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment