我已经在应用商店里有一个应用。现在我想添加APNS。在开发者门户上,我设置了开发者证书并为我的应用程序启用了 APNS。我创建了一个新的配置文件并将其设置在我的应用程序中的调试下。我已删除所有其他配置文件。
当我在我的 iphone 上运行我的应用程序时,我发送了 registerForRemoteNotificationTypes 但从未得到苹果的响应,也没有调用错误委托。如果我删除 iPhone 上的应用程序并重新安装,它永远不会询问推送通知。
在过去的两天里,我已经阅读了尽可能多的关于该主题的堆栈溢出文章和教程/Apple 文档,但到目前为止似乎没有任何东西可以解决我的问题。
我检查过的其他事项:
- 检查 Entitlements.plist 文件中是否有坏密钥
- 检查下载的 .mobileprovision 文件中是否有带有开发字符串的 aps-environment
- 删除我的管理器中的所有其他配置文件 -> 设备以及钥匙串
- 更改日期在我的 iPhone 上向前一天,关机,开机,重新加载应用程序
有没有人对尝试什么有任何其他建议,或者为什么尝试在现有应用程序上设置 APNS 似乎不起作用?
请注意,我试图用 APNS 开发一个新版本,而不是问为什么发布的版本还不能工作。一旦我可以使用 APNS 进行调试,我就会选择 disto APNS。提前致谢。
[编辑] 我想你误解了我的问题。我已经阅读了文档并完成了这些步骤。事实上,同样的代码曾经一度有效,我在几个主要版本前暂时禁用了它,但现在想重新启用它。我也看过同样的教程。据我所知,主要问题不是我的代码,它的配置文件或与 Apple 的错误有关的东西,以及它如何处理现有文件或其他东西中的推送证书。
这是我的代码,但正如我所说,我不认为它在这一点上是我的代码,它与配置或其他东西有关。我已经验证我称之为,但在 IOS 开发站点上设置推送证书以及获取新的配置文件后,从未收到任何代表的回调。
[application registerForRemoteNotificationTypes:
(UIRemoteNotificationType)
(UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeSound |
UIRemoteNotificationTypeAlert) ];
代表永远不会被召唤:
- (void) application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
[Log log:TINFO :@"==== APNS didRegisterForRemoteNotifcationsWithDeviceToken ===="];
NSString *devtok = [NSString stringWithFormat:@"%@",deviceToken];
devtok = [devtok stringByReplacingOccurrencesOfString: @"" withString: @""];
devtok = [devtok stringByReplacingOccurrencesOfString: @" " withString: @""];
NSString *stok = [[[NSString alloc] initWithFormat:@"%@", devtok] autorelease];
[Log log:TINFO :@"saving ", devtok];
UpdateDevToken *utok = [[UpdateDevToken alloc] autorelease];
[utok updateDeviceToken:stok];
}
错误委托:
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
[Log log:TERR :@"==== APNS didFailToRegisterForRemoteNotificationsWithError: %@", error.localizedDescription];
}
[编辑 2] 忘了补充说我也有 didReceiveRemoteNotification:
- (void)application:(UIApplication *)application didReceiveRemoteNotification(NSDictionary *)userInfo
{
[Log log:TENT :@"==== APNS didReceiveRemoteNotification"];
}
我的代表都没有接到电话。