sant0sk1 (owner)

Fork Of

Revisions

gist: 155974 Download_button fork
public
Public Clone URL: git://gist.github.com/155974.git
Embed All Files: show embed
Objective-C #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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);
}