在设备上卸载 ios 应用程序后如何在 ios 中保留 identifierForVendor? [英] How to preserve identifierForVendor in ios after uninstalling ios app on device?

查看:39
本文介绍了在设备上卸载 ios 应用程序后如何在 ios 中保留 identifierForVendor?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个 iOS 应用程序,它调用 Web 服务进行登录,当时我将登录凭据与供应商标识符 (identifierForVendor) 一起发送到 Web 服务器,以便为这些凭据唯一标识设备.因此用户只能拥有一台设备和一个证书.

I am developing an iOS app which calls web-service for login and at that time i send login credentials to web server along with vendor identifier (identifierForVendor),to identify device uniquely for those credentials.So user can have only one device and one credential.

我用

NSString *uuid = [[UIDevice currentDevice] identifierForVendor].UUIDString

此标识符随后将存储在 Web 服务器的数据库和设备数据库中.下次当用户打开应用程序并尝试从 Web 服务器下载数据时,用户设备上的本地标识符ForVendor 将与存储在 Web 服务器上的标识符进行比较.

This identifier will then store in database of web server and also in device database.Next time when user opens application and will try to download data from web server firstly local identifierForVendor on users device will compare with identifier stored on web server.

用户卸载应用程序并重新安装时出现问题,我发现 identifierForVendor 已更改.因此用户无法继续.

Problem occurs when user uninstall app and reinstall it, I found that identifierForVendor is changed. So user cannot proceed further.

我阅读了苹果文档 UIDevice 文档

正如那里提到的,如果来自同一供应商的所有应用程序都从设备上卸载,那么在新安装来自该供应商的任何应用程序时,将采用新的 identifierForVendor.

As mention there, if all app from same vendor uninstalls from device then at time of new installation of any app from that vendor will take new identifierForVendor.

那么在我的情况下如何处理?

So how to deal with this in my case ?

推荐答案

您可以将其保存在 KeyChain 中

You may keep it in KeyChain

-(NSString *)getUniqueDeviceIdentifierAsString
{

 NSString *appName=[[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString*)kCFBundleNameKey];

 NSString *strApplicationUUID = [SSKeychain passwordForService:appName account:@"incoding"];
 if (strApplicationUUID == nil)
 {
    strApplicationUUID  = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
    [SSKeychain setPassword:strApplicationUUID forService:appName account:@"incoding"];
 }

 return strApplicationUUID;
}

这篇关于在设备上卸载 ios 应用程序后如何在 ios 中保留 identifierForVendor?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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