我在iOS7中遇到推送通知问题。
我已经为iOS6开发了一个应用程序,推送通知效果很好。但是,当我将该应用程序放在iOS7设备中时,它无法运行。
但是,发生了一些非常奇怪的事情。如果我使用开发密钥,则我的iOS7设备可以接收推送,但使用生产密钥却不能。
我可以获取我的devide令牌进行推送,但是它无法接收任何东西。
任何的想法?
这是我的代码:
Appdelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// PUSH-CODE
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
....
}
// PUSH-CODE
- (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);
}
Google只是在搜索“ ios7推送通知不起作用”,因为您的问题只是我所知道的第三个问题。这不是你的错,而是苹果的错。用户需要将手机连接到iTunes才能接收推送。有时很难恢复出厂设置,有时只是关闭设备电源。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句