我必须开发一个以特定方式使用推送通知的应用程序,我有一个非常棘手的问题:设备令牌可以本地存储在应用程序沙箱中吗?
原因如下:这个应用程序应该实现一个通知系统,允许用户仅从 iPhone 订阅某些特定事件。
因此,要做到这一点,我需要在应用程序运行时随时将 iPhone 的设备令牌发送到我的数据库,从我得到的情况来看,设备令牌仅在调用时才可用,
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
对吗?
或者以后有什么办法可以检索到这些信息吗?
谢谢。
I have to developp an app that uses Push Notification in a particular way, and I had a pretty tricky question : can the device token be stored locally in the app sandbox?
Here's the why : this app should implement a notification system that allows the user to subscribe for some particular events only, from the iphone.
So to do so, I need to send to my database the Device Token of the iPhone at any time when the app is running, and from what I get, the device token is only avaliable when the
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
is called right?
Or is there any way to retrieve this information later?
Thanks.
发布评论
评论(2)
推送通知编程指南 但是建议您不要在本地存储令牌:
……
The push notification programming guide however recommends you not to store the token locally:
…
您应该将其存储在手机上的某个位置。 NSUserDefaults 是一个不错的地方,因为它不是很大的数据,并且您可以在之后轻松检索它。我还建议将其保存在您的服务器上,并且仅在令牌更改时更新它。
You should store it somewhere on the phone. NSUserDefaults is a decent place to do it since it's not a big piece of data and you can retrieve it easily afterwards. I would also recommend saving it on your server, and only updating it if the token changes.