Created
December 4, 2014 22:12
-
-
Save bithavoc/e7a4c756dc6b085e8913 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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