gpt4 book ai didi

ios - 推送通知在 iOS 7 中不起作用,但在 iOS 6 中有效

转载 作者:可可西里 更新时间:2023-11-01 05:36:00 25 4
gpt4 key购买 nike

我在 iOS7 中遇到推送通知问题。

我为 iOS6 开发了一个应用程序,推送通知效果很好。但是,当我将该应用程序放入 iOS7 设备时,它无法运行。

但奇怪的事情发生了。如果我使用 Development key,我的 iOS7 设备可以接收推送,但是使用 Production key,它不能。

我可以获得用于推送的设备 token ,但它无法接收任何东西。

有什么想法吗?

这是我的代码:

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 推送通知不起作用”,因为您的问题只是我知道的第 3 个问题。这不是你的错,而是苹果的错。用户需要将他们的手机连接到 iTunes 才能接收推送。有时硬恢复出厂设置,有时只是关闭设备。

  • iOSX.0 是“快来测试吧”
  • iOSX.1 是“我们试图根据您的意见修复一些错误”
  • iOSX.2 稳定版,您可以自由开发,无论如何我们在 3 个月内推出下一个 X.0 版本:)

关于ios - 推送通知在 iOS 7 中不起作用,但在 iOS 6 中有效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19339103/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com