我在哪里可以存储供以后使用iOS设备令牌? [英] Where can I store the iOS device token for later use?

查看:102
本文介绍了我在哪里可以存储供以后使用iOS设备令牌?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在我得到通过 didRegisterForRemoteNotificationsWithDeviceToken 设备令牌。不过,我需要在令牌以后使用该设备在我的应用我的用户登录后。

Right now I'm getting the device token via didRegisterForRemoteNotificationsWithDeviceToken. However, I need to use the device token later on in my application after my user logs in.

我怎样才能从其他地方访问deviceToken应用以后,如果我不能,如何/我在哪里可以将其存储在 didRegisterForRemoteNotificationsWithDeviceToken ,所以我可以在以后检索?

How can I access the deviceToken from elsewhere in application later on, and if I cannot, how/where can I store it in didRegisterForRemoteNotificationsWithDeviceToken so I can retrieve it later on?

推荐答案

最简单的方法是使用<一个href=\"https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSUserDefaults_Class/\"相对=nofollow> NSUserDefaults的

The most simple way is to use NSUserDefaults

保存:

NSUserDefaults * ud = [NSUserDefaults standardUserDefaults];
[ud setObject:myPushToken forKey:@"currentPushToken"];
[ud synchronize];

Restroing:

Restroing:

NSString * currentPushToken = [[NSUserDefaults standardUserDefaults] objectForKey:@"currentPushToken"];

这篇关于我在哪里可以存储供以后使用iOS设备令牌?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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