I am having an app which works on iOS 7 and later. Push notification was working in development mode last day but not now.
I am registering for push like this
if ([application respondsToSelector:@selector(isRegisteredForRemoteNotifications)])
{
// iOS 8 Notifications
[application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
//enabled = [application isRegisteredForRemoteNotifications];
}
else
{
// iOS < 8 Notifications
[application registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)];
//UIRemoteNotificationType types = [application enabledRemoteNotificationTypes];
//enabled = types & UIRemoteNotificationTypeAlert;
}
// Delegate methods are
-
(void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
//register to receive notifications[application registerForRemoteNotifications];
} -
(void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
{NSString *newToken = [deviceToken description];
newToken = [newToken stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@“<>”]];
newToken = [newToken stringByReplacingOccurrencesOfString:@" " withString:@“”];
self.myDeviceToken = newToken;
[CLServerDataManager setDeviceToken:newToken];
}
- (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error
{
#if TARGET_IPHONE_SIMULATOR
NSLog(@“Failed to get token, error: %@”, error);
[CLServerDataManager setDeviceToken:@“dummy”];
self.myDeviceToken = @“dummy”;
#endif
}
And push was working till last day. and certificates are made with the www.raywenderlich.com site.
But now I have noticed that methods
didRegisterForRemoteNotificationsWithDeviceToken:
didFailToRegisterForRemoteNotificationsWithError
not calling and I am not getting the device token.
I am trying this code for APNS
NSUUID *identifierForVendor = [[UIDevice currentDevice] identifierForVendor];
NSString *deviceId = [identifierForVendor UUIDString];
But both are not working.
please let me know what could be the issue. Thanks in advance