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

查看:114
本文介绍了如何在设备上卸载ios app后保留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.

我得到了identifierForVendor

I got identifierForVendor with

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

此标识符将存储在Web服务器的数据库中当用户打开应用程序并尝试从Web服务器下载数据时,用户设备上的本地identifierForVendor将与存储在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 Documentation

如上所述,如果全部来自同一供应商的应用程序从设备卸载,然后在从该供应商新安装任何应用程序时将采用新的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 app后保留ios中的identifierForVendor?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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