Enr*_*iMR 4 apple-push-notifications ios ios6 ios7
我在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);
}
Run Code Online (Sandbox Code Playgroud)
小智 5
刚刚谷歌搜索"ios7推送通知无法正常工作",因为你的问题只是我已经知道的第3个响应.这不是你的错,而是Apple的错.用户需要将手机连接到iTunes以接收推送.有时硬盘重置,有时只需关闭设备.
| 归档时间: |
|
| 查看次数: |
3591 次 |
| 最近记录: |