ios - 如何在 iOS 中获取唯一的设备 ID

标签 ios objective-c swift deviceid

我正在开发 iOS 应用程序以实现推送通知功能,我需要将 iOS 设备的唯一设备 ID 发送到服务器,在为每个设备获取的 android secure androd id 中,有什么方法可以获取 iOS 的唯一设备 ID。 我找到了一些答案 vendor id 和 ad id are they unique

code:
Secure.getString(getContext().getContentResolver(),Secure.ANDROID_ID); 

最佳答案

要获取UUID,您可以使用此代码

UIDevice *currentDevice = [UIDevice currentDevice];
NSString *deviceId = [[currentDevice identifierForVendor] UUIDString];

但对于推送通知,您需要设备 token ,它会在用户接受权限后创建,UIApplication 委托(delegate)方法将调用

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken

关于ios - 如何在 iOS 中获取唯一的设备 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39265253/

相关文章:

ios - 需要登录弹出应用内购买问题?

objective-c - 是否可以使用 CGContextScaleCTM 创建视网膜图像?

swift - 修复 Swift 3 中的警告 "C-style for Statement is deprecated"

swift - Vapor Fluent 数据库事务不是原子的

ios - 在 Swift 中隐藏 UISearchBar

javascript - Cordova 应用程序 - 键盘显示/打开之前的事件监听器

ios - 基于 subview 自动设置容器 View 的高度

iphone - 我如何从一个字符串中取出多个 url?

objective-c - 仅在一个 View Controller 上允许自动旋转

iphone - 在iPhone中使用带有userid参数的base64 haxcode将图像上传到服务器