#pragma mark -
#pragma mark Application lifecycle
- (void)applicationDidFinishLaunching:(UIApplication *)application {
[window addSubview:viewController.view];
[window makeKeyAndVisible];
NSLog(@"Registering for push notifications...");
[[UIApplication sharedApplication]
registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeSound)];
}
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken1 {
NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults];
NSString *str = [NSString stringWithFormat:@"%@",deviceToken1];
NSLog(@"%@",str);
NSString *stringWithoutOpenB = [str stringByReplacingOccurrencesOfString:@"<" withString:@""];
NSString *stringWithoutCloseB = [stringWithoutOpenB stringByReplacingOccurrencesOfString:@">" withString:@""];
NSString *trimmedString = [stringWithoutCloseB stringByReplacingOccurrencesOfString:@" " withString:@""];
if (standardUserDefaults) {
[standardUserDefaults setObject:trimmedString forKey:@"DT"];
[standardUserDefaults synchronize];
}
NSLog(@"%@",str);
}
- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err {
NSString *str = [NSString stringWithFormat: @"Error: %@", err];
NSLog(@"%@",str);
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
for (id key in userInfo) {
NSLog(@"key: %@, value: %@", key, [userInfo objectForKey:key]);
}
}
No comments:
Post a Comment