Skip to content

Instantly share code, notes, and snippets.

@markbates
Created July 25, 2009 20:33
Show Gist options
  • Select an option

  • Save markbates/154957 to your computer and use it in GitHub Desktop.

Select an option

Save markbates/154957 to your computer and use it in GitHub Desktop.

Revisions

  1. markbates created this gist Jul 25, 2009.
    19 changes: 19 additions & 0 deletions gistfile1.m
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    - (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);
    }