iPhone APNs 开始推送之前需要等待一段时间吗?
我正在两个测试应用程序上运行推送通知。我在两天内运行的第一个测试应用程序。今晚我尝试实现推送通知的第二个测试应用程序,并且一直在努力解决它。我可以交换证书,并且第一个应用程序收到通知,但是当我将 .pem 用于第二个应用程序时,什么也没有发生。
今晚我已经完成了整个过程两次,试图让 Push 为第二个应用程序工作。我唯一的结论是,考虑到我可以交换 .pems 并且它适用于第一个应用程序,第二个 .pem 出了问题,或者在推送开始工作之前可能有一段等待时间,而我只是没有在我第一次设置时意识到这一点吗?
编辑:问题是我
-(BOOL)application: didFinishLaunchingWithOptions:
在我的委托中使用而不是使用
-(void)applicationDidFinishLaunching:
我正在做的事情......
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Register for Push Notifications
UIRemoteNotificationType notifyTypes = (UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeBadge);
}
当我应该做的时候
-(void)applicationDidFinishLaunching:(UIApplication *)application {
//NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults];
// Register for Push Notifications
UIRemoteNotificationType notifyTypes = (UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound |UIRemoteNotificationTypeBadge);
}
I am running Push Notification on two test apps. The first test app I got working over a 2 day period. The 2nd test app I tried to implement Push Notification tonight and have been banging my head over it. I am able to swap the certificates and the 1st app receives notifications, but when I use the .pem for the 2nd app, nothing happens.
I have gone through the entire process twice tonight, trying to get the Push to work for this 2nd app. My only conclusion, given that I can swap the .pems and it will work for the 1st app, is that something is wrong with the 2nd .pem or maybe there is a waiting period before the push starts working, and I just didn't realize it during my first setup?
Edit: The problem was that I was using
-(BOOL)application: didFinishLaunchingWithOptions:
in my delegate and not using
-(void)applicationDidFinishLaunching:
I was doing...
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Register for Push Notifications
UIRemoteNotificationType notifyTypes = (UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeBadge);
}
When I should have been doing
-(void)applicationDidFinishLaunching:(UIApplication *)application {
//NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults];
// Register for Push Notifications
UIRemoteNotificationType notifyTypes = (UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound |UIRemoteNotificationTypeBadge);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 Push 开始工作之前有一个等待期,尽管根据我的经验,这个等待期通常很短。确保配置门户的应用程序 ID 页面中的小点为绿色 - 并确保它适用于正确的应用程序 ID 和环境(例如,如果您在调试中运行,请确保将其配置为发展)。
除此之外,这也可能是您的 .pem 或配置文件的问题。
来自 Apple Push 参考指南:
当您尝试推送时是否出现任何错误?
There is a waiting period before Push starts working, though in my experience said period is generally quite short. Make sure that the little dot is green in your App ID page of the provisioning portal - and make sure that it is for the correct App ID and environment (for example, if you're running in debug, make sure that it is configured for development).
Apart from that, it could be an issue with your .pem or provisioning profile as well.
From the Apple Push Reference guide:
Do you have any errors coming up when you attempt to push?