I need to implement APNS in my project, I created APNS SSL in the developers portal, and with this I created a new position profile for this. Using an SSL certificate, I created a P12 file and then combined it with a PEM file. I get a pop-up that the application wants to send you a notification ..... I accept this, but still I have not received the device token.
In didfinishLaunching I use this part
float ver = [[[UIDevice currentDevice] systemVersion] floatValue]; if(ver >= 8 && ver<9) { if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerUserNotificationSettings:)]) { [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]]; [[UIApplication sharedApplication] registerForRemoteNotifications]; //[[UIApplication sharedApplication] registerUserNotificationSettings:settings]; } }else if (ver >=9){ [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]]; [[UIApplication sharedApplication] registerForRemoteNotifications]; } else{ //iOS6 and iOS7 specific code [[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeAlert]; } I have used delegate method of push notification - (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error { NSLog(@"Failed to get token, error: %@", error); } - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { for (id key in userInfo) { NSLog(@"key: %@, value: %@", key, [userInfo objectForKey:key]); } }
ios objective-c iphone objective-c-blocks
Subhash Kumar Nov 05 '15 at 9:47 2015-11-05 09:47
source share