I'm having problems with push notifications in iOS7.
I developed an application for iOS6 and push notifications work very well. But, when I put this application on the iOS7 device, it does not start.
But something is very strange. If I use the development key, my iOS7 device can receive push, but with the Production key it cannot.
I can get my tokenide for push, but it can't get anything.
Any idea?
This is my code:
Appdelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
....
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
NSString *token = [[deviceToken description] stringByTrimmingCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@"<>"]];
token = [token stringByReplacingOccurrencesOfString:@" " withString:@""];
NSLog(@"Token: %@", token);
[[NSUserDefaults standardUserDefaults] setObject:token forKey:@"deviceToken"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
NSLog(@"Failed to get token, error: %@", error);
}
source
share