Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
- // Override point for customization after application launch.
- // Add the view controller's view to the window and display.
- [self.window addSubview:viewController.view];
- [self.window makeKeyAndVisible];
- NSLog(@"Registering for push notifications...");
- [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
- (UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
- return YES;
- }
- - (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
- NSString *str = [NSString stringWithFormat:@"Device Token=%@",deviceToken];
- NSLog(@"This is device token%@", deviceToken);
- }
- - (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err {
- NSString *str = [NSString stringWithFormat: @"Error: %@", err];
- NSLog(@"Error %@",err);
- }
- - (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
- {
- NSString *token = [[deviceToken description] stringByTrimmingCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@"<>"]];
- token = [token stringByReplacingOccurrencesOfString:@" " withString:@""];
- NSLog(@"content---%@", token);
- }
- - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
- [self.window addSubview:viewController.view];
- [self.window makeKeyAndVisible];
- NSLog(@"Registering for push notifications...");
- [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
- (UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
- return YES;
- }
- - (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
- NSString *str = [NSString stringWithFormat:@"Device Token=%@",deviceToken];
- NSLog(@"%@", str);
- }
- - (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err {
- NSString *str = [NSString stringWithFormat: @"Error: %@", err];
- NSLog(@"%@",str);
- }
- // Prepare the Device Token for Registration (remove spaces and < >)
- NSString *devToken = [[[[deviceToken description]
- stringByReplacingOccurrencesOfString:@"<"withString:@""]
- stringByReplacingOccurrencesOfString:@">" withString:@""]
- stringByReplacingOccurrencesOfString: @" " withString: @""];
- NSString *str = [NSString
- stringWithFormat:@"Device Token=%@",devToken];
- UIAlertView *alertCtr = [[[UIAlertView alloc] initWithTitle:@"Token is " message:devToken delegate:self cancelButtonTitle:nil otherButtonTitles: nil] autorelease];
- [alertCtr show];
- NSLog(@"device token - %@",str);
- NSString *deviceTokenString = deviceToken.description;
- deviceTokenString = [deviceTokenString stringByReplacingOccurrencesOfString:@"[< >]" withString:@"" options:NSRegularExpressionSearch range:NSMakeRange(0, deviceTokenString.length)];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement