简体   繁体   English

iPhone SDK推送通知

[英]iPhone SDK Push Notification

I have setup push notifications in the apple developer panel and added the code to my application. 我在apple开发人员面板中设置了推送通知,并将代码添加到我的应用程序中。

It works fine on the phone using a development profile but if I use a distribution (ad-hoc) profile so that I can give it to a few users for testing it gives an error and crashes, the log gives the following error 它在使用开发配置文件的手机上工作正常,但如果我使用分发(ad-hoc)配置文件以便我可以将它提供给少数用户进行测试,则会出现错误并导致崩溃,日志会出现以下错误

Code: 码:

Thu Jun 25 22:22:35 unknown SpringBoard[729] <Warning>: *** Assertion failure in -[SBRemoteNotificationServer registerApplication:forEnvironment:withTypes:], /SourceCache/SpringBoard/SpringBoard-919.5/SBRemoteNotificationServer.m:633
Thu Jun 25 22:22:35 unknown SpringBoard[729] <Error>: *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'no connection found for environment production'

I am using the following code in the app 我在应用程序中使用以下代码

Code: 码:

[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)];

The thing I don't understand is why it works perfectly using a development profile but with ad-hoc it crashes. 我不明白的是为什么它使用开发配置文件完美地运行,但是ad-hoc它崩溃了。

Does anyone know what would cause this?, I've tried changing lots of things to try and find the issue but have found nothing. 有谁知道会导致什么?,我试过改变很多东西来尝试找到问题但却一无所获。

I was having this problem as well. 我也有这个问题。 The symptom was the app would crash when calling [[UIApplication sharedApplication] registerForRemoteNotificationTypes:...]. 症状是应用程序在调用[[UIApplication sharedApplication] registerForRemoteNotificationTypes:...]时会崩溃。

It seems that once a given device loads an APNs Distribution Profile, trying to later go back to using an APNs Development Profile will not work unless you change the App ID. 似乎一旦给定设备加载APNs分发配置文件,尝试稍后返回使用APNs开发配置文件将无法工作,除非您更改应用程序ID。

If you create a user-defined build setting in Xcode, as suggested here: 如果您在Xcode中创建用户定义的构建设置,如下所示:

iPhone "Good Practices" iPhone“好做法”

you can stop the crashing and also have both versions co-exist on the same device for testing, etc. 你可以停止崩溃,同时让两个版本共存于同一台设备上进行测试等。

I solved this problem on one of my development devices by installing a random application from the App Store which uses push notifications. 我通过从App Store安装使用推送通知的随机应用程序,在我的一个开发设备上解决了这个问题。 In this case, I installed the Le Monde.fr application. 在这种情况下,我安装了Le Monde.fr应用程序。 After I ran that application once, my own application no longer crashed. 在我运行该应用程序一次后,我自己的应用程序不再崩溃。

我设法通过重新请求所有证书等来实现这一点。

我通过转到设置,然后切换顶部“主”推送通知关闭,然后重新打开来解决这个问题。

冗长但确定的解决方案是“删除所有内容和设置”。

Here's my solution, and it has to do with how adhoc profiles work. 这是我的解决方案,它与adhoc配置文件的工作方式有关。 Adhoc profiles cannot be installed via xCode. 无法通过xCode安装Adhoc配置文件。 You need to build and archive the app, and install using iTunes or the organizer. 您需要构建和存档应用程序,并使用iTunes或组织者进行安装。 That fixed it for me. 这为我解决了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM