iPhone APNs 开始推送之前需要等待一段时间吗?

发布于 2024-09-25 01:01:41 字数 1180 浏览 2 评论 0原文

我正在两个测试应用程序上运行推送通知。我在两天内运行的第一个测试应用程序。今晚我尝试实现推送通知的第二个测试应用程序,并且一直在努力解决它。我可以交换证书,并且第一个应用程序收到通知,但是当我将 .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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鸠书 2024-10-02 01:01:41

在 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:

You have to modify the profile in some minor way (for example, toggle an option) for the portal to generate a new provisioning profile. If the profile isn't so “dirtied,” you're given the original profile without the push entitlements.

Do you have any errors coming up when you attempt to push?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文