Apple 推送通知 - 从生产应用程序获取空推送令牌 - 将在修复配置文件问题后发送推送令牌 [英] Apple push notifications - getting empty push token from production app - will push tokens be sent after fix provisioning profile issue

查看:39
本文介绍了Apple 推送通知 - 从生产应用程序获取空推送令牌 - 将在修复配置文件问题后发送推送令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在 iPhone 应用中添加了接收推送通知.一切都在测试/沙盒环境中运行,我们从应用程序获取令牌 ID,并可以从我们的服务器发送推送通知.

We added receiving push notifications to an iPhone app. Everything was working in the test/sandbox environment, we were getting token id's from the app and could send push notifications from our server.

但是现在该应用程序已获得批准并从 Appstore 出来,我们收到了发送到我们服务器的空推送令牌/通知 ID.我们已经有 600 多个...请注意,最终用户确实会弹出窗口以批准在应用程序中接收通知,该应用程序只是在批准后向我们的服务器发送空令牌.所以很可能空令牌是由 APNS 服务器分发的.

But now the app is approved and came out of the Appstore we were getting empty push tokens/notifications id's send to our server. We already have over 600 of them... Note that end users do get the popup to approve of receiving notifications in the app, the app is just sending empty tokens to our server after approval. So probably empty tokens are handed out by the APNS server.

以下问题向我们表明,这可能是由于我们用于构建应用商店的配置文件中缺少推送通知"权利:我如何检查iOS 分发配置文件是否启用了推送通知?

The following issue showed us that this is probably due to missing 'push notification' entitlement in the provisioning profile we used to make the build for the app store: How do I check if an iOS distribution provisioning profile has push notifications enabled?

缺少的权利是由于 Apple 的provisiong protal 网站中的一个错误,但在下载新的之前修改任何现有配置文件"之后,如下文所述http://developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ProvisioningDevelopment/ProvisioningDevelopment.html

The missing entitlement was due to a bug in Apple's provisiong protal website, but after 'Modify any existing profile before you download the new one' as mentioned in the following article http://developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ProvisioningDevelopment/ProvisioningDevelopment.html

我们现在在 .mobileprovision 文件中有正确的权利:

We now have the correct entitlement in our .mobileprovision file:

<key>Entitlements</key>
<dict>
 ..   
 <key>aps-environment</key>
 <string>production</string>
 ..

所以我们正在重建我们的应用程序并将其添加到商店.并希望届时收到推送通知.

So we are rebuilding our app and adding it to the store. And hoping to get push notifications then.

我希望以上内容可以帮助其他人.但现在要回答我的实际问题:当 600 多名已下载当前版本的用户在商店外安装下一个更新时,我们是否也会开始接收新的推送令牌?或者我们是否需要向我们的应用程序添加一些初始代码?registerForRemoteNotifications 方法现在只在应用程序启动时调用.当推送令牌id从空('')更改为实际令牌时是否也会触发?当然,我们不想再等一个(小)周以等待新的 AppStore 批准,然后才发现推送通知对某些用户仍然不起作用.我希望那里的一些专家可以告诉我们.

I hope the above might help some others. But now to get to my actual question: Will we start receiving new push tokens also for the 600+ users that already downloaded the current version when they install the next update out of the store? Or do we need to add some initial code to our app? The registerForRemoteNotifications method is right now only called on application startup. Will it also be triggered when the push token id is changed from empty ('') to an actual token? Of course we do not want to wait another (small) week for the new AppStore approval and only then find out that push notification still aren't working for some users. I'm hoping some expert out there can tell us.

注意:我们正在使用 MonoTouch 开发的 iPhone 应用,并使用(旧)APNS-Sharp 库从我们的服务器发送通知,但我认为这些细节与此问题无关.

Note: We are using an iPhone app developed in MonoTouch, and using the (old) APNS-Sharp library to send the notifications from our server, but I don't think those details are relevant for this issue.

推荐答案

当那 600 多个用户安装下一个更新并再次运行应用程序时,您的应用程序将调用 registerForRemoteNotifications(因为您说您调用它在启动时),并将获得非空设备令牌(当 application:didRegisterForRemoteNotificationsWithDeviceToken: 被调用时).Apple 在他们的文档中声明您应该始终在启动时调用此方法,而不是使用设备令牌的缓存副本,因为不能保证设备令牌保持不变.所以你应该没有任何问题.

When those 600+ users install the next update and run the application again, your application will call registerForRemoteNotifications (since you said you call it on startup), and will get the non empty device token (when application:didRegisterForRemoteNotificationsWithDeviceToken: is called). Apple state in their docs that you should always call this method at startup instead of using a cached copy of the device token, because the device token is not guaranteed to remain the same. So you shouldn't have any problem.

以下是 APNS 文档中的相关引用:

Here's the relevant quote from the APNS docs :

应用程序应该在每次启动时注册并提供提供当前令牌.它调用registerForRemoteNotificationTypes: 方法开始注册过程.该方法的参数取一个UIRemoteNotificationType(或者,对于 OS X,一个 NSRemoteNotificationType)位掩码指定通知的初始类型应用程序希望接收——例如,图标标记和声音,但不是警报消息.在 iOS 中,用户可以随后修改在通知"首选项中启用的通知类型设置应用程序.在 iOS 和 OS X 中,您都可以检索通过调用当前启用的通知类型enabledRemoteNotificationTypes 方法.操作系统不徽章图标、显示警报消息或播放警报声音(如果有)这些通知类型未启用,即使已指定在通知负载中.

An application should register every time it launches and give its provider the current token. It calls the registerForRemoteNotificationTypes: method to kick off the registration process. The parameter of this method takes a UIRemoteNotificationType (or, for OS X, a NSRemoteNotificationType) bit mask that specifies the initial types of notifications that the application wishes to receive—for example, icon-badging and sounds, but not alert messages. In iOS, users can thereafter modify the enabled notification types in the Notifications preference of the Settings application. In both iOS and OS X, you can retrieve the currently enabled notification types by calling the enabledRemoteNotificationTypes method. The operating system does not badge icons, display alert messages, or play alert sounds if any of these notifications types are not enabled, even if they are specified in the notification payload.

这也是相关的:

通过每次请求设备令牌并将其传递给提供者当你的应用程序启动时,你帮助确保提供者具有设备的当前令牌.如果用户将备份恢复到除为其创建备份的设备或计算机之外的设备或计算机(例如,用户将数据迁移到新设备或计算机),他或者她必须至少启动应用程序一次才能接收再次通知.如果用户将备份数据恢复到新设备或计算机,或重新安装操作系统,设备令牌变化.此外,永远不要缓存设备令牌并将其提供给您的提供者;随时从系统获取令牌.如果您的应用程序之前已注册,请致电registerForRemoteNotificationTypes:在操作系统中的结果立即将设备令牌传递给委托,而不会产生额外的开销.

By requesting the device token and passing it to the provider every time your application launches, you help to ensure that the provider has the current token for the device. If a user restores a backup to a device or computer other than the one that the backup was created for (for example, the user migrates data to a new device or computer), he or she must launch the application at least once for it to receive notifications again. If the user restores backup data to a new device or computer, or reinstalls the operating system, the device token changes. Moreover, never cache a device token and give that to your provider; always get the token from the system whenever you need it. If your application has previously registered, calling registerForRemoteNotificationTypes: results in the operating system passing the device token to the delegate immediately without incurring additional overhead.

这篇关于Apple 推送通知 - 从生产应用程序获取空推送令牌 - 将在修复配置文件问题后发送推送令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆