UIDevice uniqueIdentifier가 권장되지 않음 - 이제 어떻게 해야 합니까?
UIDevice uniqueIdentifier 속성은 iOS 5에서 더 이상 사용되지 않으며 iOS 7 이상에서는 사용할 수 없는 것으로 나타났습니다.사용할 수 있는 대체 메서드나 속성이 없거나 곧 제공될 것으로 보이지 않습니다.
기존 앱의 대부분은 특정 기기를 고유하게 식별하기 위해 이 속성에 크게 의존하고 있습니다.이 문제는 앞으로 어떻게 대처해야 할까요?
2011-2012년 문서에서 제시된 내용은 다음과 같습니다.
특별한 고려 사항
propertyuniqueIdentifier는 .앱 하려면 , 「」를 해 주세요.
CFUUIDCreate
를UUID
하여 기본NSUserDefaults
를 누릅니다
그러나 사용자가 앱을 제거했다가 다시 설치하는 경우 이 값은 동일하지 않습니다.
" " " UUID에 의해 CFUUIDCreate
사용자가 앱을 제거했다가 다시 실행하면 매번 새 앱을 얻을 수 있습니다.
하지만 넌 그걸 원할지도 몰라고유하지 않습니다. 즉, 사용자가 앱을 제거했다가 다시 실행해도 동일하게 유지됩니다.디바이스별 식별자의 신뢰성이 가장 높은 것은 MAC 주소인 것 같기 때문에, 이것은 약간의 노력이 필요합니다.할 수 있다MAC를 쿼리하여 UUID로 사용합니다.
편집: 물론 항상 같은 인터페이스의 MAC에 문의해야 합니다.하는 것이 가장 좋은 방법일 것 같다 en0
인터페이스에 IP/가 다운되어 있지 않아도, MAC 는 항상 존재합니다.
편집 2: 다른 사람들이 지적한 바와 같이 iOS 6 이후 권장되는 솔루션은 [UIDevice identifier ForVendor]입니다.대부분의 경우 오래된 것을 대체하기 위해 사용할 수 있습니다.-[UIDevice uniqueIdentifier]
(단, 앱을 처음 시작할 때 생성되는 UUID는 Apple이 사용하길 원하는 것 같습니다.
편집 3: 이 주요 포인트는 코멘트 노이즈로 손실되지 않습니다.MAC를 UUID로 하여해시합니다.이 해시는 재설치 및 앱을 통해서도 항상 같은 결과를 생성합니다(해시가 같은 방법으로 이루어지는 경우).어쨌든, 오늘날(2013년)에는, iOS< 6.0 의 「안정적인」디바이스 식별자가 필요한 경우를 제외하고, 이 기능은 더 이상 필요 없습니다.
편집 4: iOS 7에서는 MAC를 조회할 때 항상 고정값을 반환하여 특히 ID 스킴의 베이스가 되는 MAC를 저지합니다.따라서 [UIDevice identifierForVendor]를 사용하거나 설치별 UUID를 생성해야 합니다.
대신 할 수 .UDID
는 on절 on on에 카테고리를 썼다.UIDevice
어떤 종류의 정보를 만들어 낼 것이다.UDID
MAC 아이디
github에서 코드를 찾을 수 있습니다.
@moonlight에서 제안한 링크를 바탕으로 몇 가지 테스트를 해봤는데 가장 좋은 해결책인 것 같습니다.@이 는 @DarkDust를 합니다.en0
언제든지 이용할 수 있습니다.
두 이 있습니다.
uniqueDeviceIdentifier
MAC+CFBundleIdentifier®MD5)
★★★★★★★★★★★★★★★★★」uniqueGlobalDeviceIdentifier
(MAC) MD5) MD5를 사용합니다.
(실제 장치를 사용하여) 수행한 테스트 아래:
#import "UIDevice+IdentifierAddition.h"
NSLog(@"%@",[[UIDevice currentDevice] uniqueDeviceIdentifier]);
NSLog(@"%@",[[UIDevice currentDevice] uniqueGlobalDeviceIdentifier]);
- (WIFIXXXXXXXX21f1f19edff198e2a2356bf4XXX - (WIFI)
- (WIFI) GlobalAppXXXX7dc3c577446a2bcbd77935bdXXX - (WIFI)글로벌 앱UDID- (XXXXXX21f1f19edff198e2a2356bf4XXX - (3G)
- ( GlobalAppXXXX7dc3c577446a2bcbd77935bdXXX - (3G)글로벌 앱UDIDXXXX21f1f19edff198e2a2356bf4XXX-(GPRS)
- ( GlobalAppXXX7dc3c577446a2bcbd77935bdXXX - (GPRS)글로벌 앱- ( 모드 XXX21f1f19edff198e2a2356bf4XXX - (AirPlane »)
- (AirPlane 모드 XXX7dc3c577446a2bcbd77935bdXXX - (AirPlane™) -XXXX21f1f19edff198e2a2356bf4XXX - (Wi-Fi) XXX7dc3c577446a2bcbd77935bdXXXX (Wi-Fi)를 삭제하고 설치한 후
유용했으면 좋겠다.
★★★★★★
의 이 더하지 않습니다. 왜냐하면 iOS 7은 더 이상 유용하지 않습니다.uniqueIdentifier
할 수 되어, 00:00:00::00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00da를 합니다.
이것 좀 봐
키체인을 할 수 있습니다.NSUserDefaults
UUID
성자에 의해 되었습니다.CFUUIDCreate
.
수 .UUID
의한 , 및 「」를 합니다.UUID
같은 애플리케이션에 대해서는, 유저가 언인스톨 했다가 재인스톨 할 수도 있습니다.
UUID
는 사용자에 의해 디바이스가 리셋되었을 때 바로 재생성됩니다.
SFHFKeychainUtils에서 이 방법을 시도했는데, 매우 효과가 있습니다.
자체 UUID를 생성하여 키체인에 저장합니다.따라서 앱이 제거되어도 지속됩니다.대부분의 경우 사용자가 디바이스 간에 이행해도(예를 들어 완전 백업 및 다른 디바이스로의 restore 등) 지속됩니다.
사실상 사용자 고유의 ID가 됩니다.(디바이스 식별자보다 우수합니다).
예:
.UUID
같이
- (NSString *)createNewUUID
{
CFUUIDRef theUUID = CFUUIDCreate(NULL);
CFStringRef string = CFUUIDCreateString(NULL, theUUID);
CFRelease(theUUID);
return [(NSString *)string autorelease];
}
다음 .KEYCHAIN
이치첫 출시 후에는 키 체인에서 간단히 사용할 수 있으므로 재생성할 필요가 없습니다.키체인을 사용하여 저장하는 주된 이유는 다음과 같습니다.「 」를 UUID
사용자가 앱을 완전히 제거한 후 다시 설치하더라도 키체인은 지속됩니다. 따라서 이것은 영구적인 저장 방식이며 키는 항상 고유합니다.
#import "SSKeychain.h"
#import <Security/Security.h>
애플리케이션 기동시에, 다음의 코드를 포함합니다.
// getting the unique key (if present ) from keychain , assuming "your app identifier" as a key
NSString *retrieveuuid = [SSKeychain passwordForService:@"your app identifier" account:@"user"];
if (retrieveuuid == nil) { // if this is the first time app lunching , create key for device
NSString *uuid = [self createNewUUID];
// save newly created key to Keychain
[SSKeychain setPassword:uuid forService:@"your app identifier" account:@"user"];
// this is the one time process
}
SSKeychain.m 및 .h 파일을 sskeychain에서 다운로드하고 SSKeychain.m 및 .h 파일을 프로젝트에 드래그하여 "Security.framework"를 추가합니다.나중에 UUID를 사용하려면 다음 명령을 사용합니다.
NSString *retrieveuuid = [SSKeychain passwordForService:@"your app identifier" account:@"user"];
다음을 사용할 수 있습니다.
[UIDevice currentDevice].identifierForVendor.UUIDString
Apple의 문서에서는 identifierForVender에 대해 다음과 같이 설명하고 있습니다.
이 속성 값은 동일한 장치에서 실행되는 동일한 공급업체의 앱에 대해 동일합니다.다른 벤더의 동일한 디바이스의 앱과 벤더에 관계없이 다른 디바이스의 앱에 대해 다른 값이 반환됩니다.
하다, 하다, 하다, 하다를 사용하는 것도 해 보는 것이 것 .OpenUDID
된 '드롭인'의 대체품입니다.UDID
.
★★★★★★★★★★★★★★★★★★★★★★★★★UDID
다음 기능이 필요합니다.
- 유일하거나 충분히 유일하다(낮은 확률의 충돌은 아마도 매우 허용될 것이다)
- 재부팅, 복원, 언인스톨 후에도 지속성 유지
- 다양한 벤더의 앱에서 이용 가능(CPI 네트워크를 통해 사용자를 획득하는 데 유용) -
OpenUDID
님은 위의 조건을 충족하고 있으며, 나중에 검토할 수 있도록 Opt-Out 메커니즘도 내장되어 있습니다.
http://OpenUDID.org 에서 대응하는 GitHub 를 가리키고 있는 것을 확인합니다.이게 도움이 됐으면 좋겠네요!
참고로 MAC 주소의 대체는 피하고 싶습니다.MAC 주소는 매력적이고 보편적인 솔루션처럼 보이지만, 이 낮은 위치에 있는 과일에 독이 들어 있는지 확인하십시오.MAC 주소는 매우 기밀성이 높기 때문에, Apple은 「SUMIT THIS APP」라고 말하기 전에, 이 주소에의 액세스를 회피할 가능성이 있습니다.MAC 네트워크 주소는, 프라이빗 LAN(WLAN) 또는 그 외의 가상 프라이빗 네트워크(VPN)상의 특정의 디바이스를 인증하기 위해서 사용됩니다.이것보다, 한층 더 기밀성이 높아집니다.
나는 애플이 이 변화로 많은 사람들을 짜증나게 했다고 확신한다.iOS용 부기 앱을 개발하여 다양한 기기에서 변경된 사항을 동기화하는 온라인 서비스를 제공하고 있습니다.이 서비스는 모든 디바이스와 디바이스로 전파해야 하는 변경사항의 데이터베이스를 유지합니다.따라서 어떤 장치가 어떤 장치인지 아는 것이 중요합니다.UIDevice uniqueIdentifier를 사용하여 디바이스를 추적하고 있습니다.그 가치는 다음과 같습니다.
UUID를 생성하여 사용자 기본값으로 저장하시겠습니까?사용자가 앱을 삭제해도 지속되지 않으므로 사용할 수 없습니다.나중에 다시 설치할 경우 온라인 서비스는 새로운 디바이스 레코드를 생성하지 않아야 합니다.이것에 의해, 서버의 리소스가 낭비되어 같은 레코드를 포함한 디바이스의 리스트가 2회 이상 표시됩니다.사용자는 앱을 다시 설치하면 "밥의 아이폰"이 두 개 이상 나열될 것입니다.
UUID를 생성하여 키체인에 저장하시겠습니까?앱이 제거되어도 그대로 유지되기 때문에, 이것은 제 플랜이었습니다.그러나 iTunes 백업을 새 iOS 기기에 복원할 때 백업이 암호화되면 키 체인이 전송됩니다.이로 인해 오래된 디바이스와 새로운 디바이스가 모두 가동 중인 경우 2개의 디바이스가 동일한 디바이스 ID를 가질 수 있습니다.온라인 서비스에서는 디바이스 이름이 같은 경우에도 2개의 디바이스로 표시됩니다.
MAC 주소와 번들 ID의 해시를 생성하시겠습니까?이게 내가 필요한 최선의 해결책인 것 같아.번들 ID로 해시하면 생성된 디바이스 ID는 여러 앱에서 디바이스를 추적할 수 없으며 앱과 디바이스의 조합에 대한 고유 ID를 얻을 수 있습니다.
흥미로운 점은 Apple의 문서에서는 시스템 MAC 주소와 번들 ID 및 버전의 해시를 계산하여 Mac App Store 수신 확인을 언급하고 있다는 것입니다.그래서 아직 앱 리뷰를 통과했는지는 알 수 없지만 정책상 허용이 되는 것 같습니다.
iOS 6에서는 NSUID 클래스를 사용할 것을 권장합니다.
현재 UIDevice 문서에 있는 메시지에서uniqueIdentifier
★★★★
iOS 5.0에서는 권장되지 않습니다.필요에 따라 이 클래스의 identifierForVendor 속성 또는 ASIdentifierManager 클래스의 advertisingIdentifier 속성을 사용하거나 NSUID 클래스의 UUID 메서드를 사용하여 UUID를 생성하여 사용자 기본 데이터베이스에 씁니다.
도움이 될 수 있음: 아래 코드를 사용하면 단말기를 지우는(포맷하는) 경우를 제외하고 항상 고유합니다.
목표-C:
옵션 1: 이것은 설치 시마다 변경됩니다.
UIDevice *uuid = [NSUUID UUID].UUIDString;
옵션 2: 이것은 벤더/개발자의 Apple 계정별로 고유합니다.
UIDevice *myDevice = [UIDevice currentDevice];
NSString *uuid = [[myDevice identifierForVendor] UUIDString];
스위프트 5X:
옵션 1: 이것은 설치 시마다 변경됩니다.
let uuid = UUID().uuidString
옵션 2: 이것은 벤더/개발자의 Apple 계정별로 고유합니다.
let myDevice = UIDevice.current
let uuid = myDevice.identifierForVendor?.uuidString
'아, 아, 아, 아, 아, 아, 아, 아, 아, 아, 아, 아, 아, 아, 아, 아, 아, 아, 아, 아, 아, 아, 아, 아, 아, 아, 아, 아, 아, 아, 아, 아.uniqueIdentifier
앱 번들 식별자와 함께 장치의 MAC 주소를 사용하여 UDID 대체로 사용할 수 있는 고유한 ID를 생성하는 오픈 소스 라이브러리(실제로 2개의 간단한 카테고리)로 이동합니다.
이 번호는 UDID와 달리 앱마다 다릅니다.
된 Import를 .NSString
★★★★★★★★★★★★★★★★★」UIDevice
및 콜 " " "[[UIDevice currentDevice] uniqueDeviceIdentifier]
다음과 같이 합니다.
#import "UIDevice+IdentifierAddition.h"
#import "NSString+MD5Addition.h"
NSString *iosFiveUDID = [[UIDevice currentDevice] uniqueDeviceIdentifier]
아래 Github에서 찾을 수 있습니다.
iOS 5용 UniqueIdentifier를 사용하는 UIDevice
카테고리는 다음과 같습니다(.m 파일만 - github 프로젝트에서 헤더를 확인합니다).
UIDevice+IdentifierAddition.m
#import "UIDevice+IdentifierAddition.h"
#import "NSString+MD5Addition.h"
#include <sys/socket.h> // Per msqr
#include <sys/sysctl.h>
#include <net/if.h>
#include <net/if_dl.h>
@interface UIDevice(Private)
- (NSString *) macaddress;
@end
@implementation UIDevice (IdentifierAddition)
////////////////////////////////////////////////////////////////////////////////
#pragma mark -
#pragma mark Private Methods
// Return the local MAC addy
// Courtesy of FreeBSD hackers email list
// Accidentally munged during previous update. Fixed thanks to erica sadun & mlamb.
- (NSString *) macaddress{
int mib[6];
size_t len;
char *buf;
unsigned char *ptr;
struct if_msghdr *ifm;
struct sockaddr_dl *sdl;
mib[0] = CTL_NET;
mib[1] = AF_ROUTE;
mib[2] = 0;
mib[3] = AF_LINK;
mib[4] = NET_RT_IFLIST;
if ((mib[5] = if_nametoindex("en0")) == 0) {
printf("Error: if_nametoindex error\n");
return NULL;
}
if (sysctl(mib, 6, NULL, &len, NULL, 0) < 0) {
printf("Error: sysctl, take 1\n");
return NULL;
}
if ((buf = malloc(len)) == NULL) {
printf("Could not allocate memory. error!\n");
return NULL;
}
if (sysctl(mib, 6, buf, &len, NULL, 0) < 0) {
printf("Error: sysctl, take 2");
return NULL;
}
ifm = (struct if_msghdr *)buf;
sdl = (struct sockaddr_dl *)(ifm + 1);
ptr = (unsigned char *)LLADDR(sdl);
NSString *outstring = [NSString stringWithFormat:@"%02X:%02X:%02X:%02X:%02X:%02X",
*ptr, *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4), *(ptr+5)];
free(buf);
return outstring;
}
////////////////////////////////////////////////////////////////////////////////
#pragma mark -
#pragma mark Public Methods
- (NSString *) uniqueDeviceIdentifier{
NSString *macaddress = [[UIDevice currentDevice] macaddress];
NSString *bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];
NSString *stringToHash = [NSString stringWithFormat:@"%@%@",macaddress,bundleIdentifier];
NSString *uniqueIdentifier = [stringToHash stringFromMD5];
return uniqueIdentifier;
}
- (NSString *) uniqueGlobalDeviceIdentifier{
NSString *macaddress = [[UIDevice currentDevice] macaddress];
NSString *uniqueIdentifier = [macaddress stringFromMD5];
return uniqueIdentifier;
}
@end
NSString+MD5Addition.m:
#import "NSString+MD5Addition.h"
#import <CommonCrypto/CommonDigest.h>
@implementation NSString(MD5Addition)
- (NSString *) stringFromMD5{
if(self == nil || [self length] == 0)
return nil;
const char *value = [self UTF8String];
unsigned char outputBuffer[CC_MD5_DIGEST_LENGTH];
CC_MD5(value, strlen(value), outputBuffer);
NSMutableString *outputString = [[NSMutableString alloc] initWithCapacity:CC_MD5_DIGEST_LENGTH * 2];
for(NSInteger count = 0; count < CC_MD5_DIGEST_LENGTH; count++){
[outputString appendFormat:@"%02x",outputBuffer[count]];
}
return [outputString autorelease];
}
@end
UIDevice-with-UniqueIdentifier-for-iOS-5 코드로부터 얻을 수 있습니다.
MAC 주소는 스푸핑할 수 있기 때문에 콘텐츠를 특정 사용자에게 연결하거나 블랙리스트와 같은 보안 기능을 구현하는 데 이러한 접근법이 사용되지 않습니다.
좀 더 연구한 결과 현재로선 우리에게 마땅한 대안이 없는 것 같다.나는 진심으로 애플이 그들의 결정을 재고하기를 바란다.
애플에게 이 주제에 대해 이메일을 보내거나 버그/기능 요청을 하는 것이 좋을지도 모른다.왜냐하면 그들은 개발자에게 미치는 모든 결과를 알지 못할지도 모르기 때문이다.
UIDevice identifierForVendor
된 것은 의 목적에맞는 입니다.iOS 6에 도입되어 있는 것은, 고객의 목적에 맞는 것입니다.
identifierForVendor
전용읽기 전용읽기 전용)
@property(nonatomic, readonly, retain) NSUUID *identifierForVendor
이 속성 값은 동일한 장치에서 실행되는 동일한 공급업체의 앱에 대해 동일합니다.다른 벤더의 동일한 디바이스의 앱과 벤더에 관계없이 다른 디바이스의 앱에 대해 다른 값이 반환됩니다.
6.0 6.0에서 된 경우UIDevice.h
iOS 5 의 경우는, 「UIDevice-with-UniqueIdentifier-for-iOS-5」링크를 참조해 주세요.
상기의 SSKeychain과 코드를 사용한다.복사/붙여넣기 코드(SSKeychain 모듈 추가):
+(NSString *) getUUID {
//Use the bundle name as the App identifier. No need to get the localized version.
NSString *Appname = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"];
//Check if we have UUID already
NSString *retrieveuuid = [SSKeychain passwordForService:Appname account:@"user"];
if (retrieveuuid == NULL)
{
//Create new key for this app/device
CFUUIDRef newUniqueId = CFUUIDCreate(kCFAllocatorDefault);
retrieveuuid = (__bridge_transfer NSString*)CFUUIDCreateString(kCFAllocatorDefault, newUniqueId);
CFRelease(newUniqueId);
//Save key to Keychain
[SSKeychain setPassword:retrieveuuid forService:Appname account:@"user"];
}
return retrieveuuid;
}
UDID를 취득하는 데 도움이 되는 코드는 다음과 같습니다.
udid = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
NSLog(@"UDID : %@", udid);
iOS 5와 iOS 6, 7의 ID를 얻기 위해 사용하는 코드입니다.
- (NSString *) advertisingIdentifier
{
if (!NSClassFromString(@"ASIdentifierManager")) {
SEL selector = NSSelectorFromString(@"uniqueIdentifier");
if ([[UIDevice currentDevice] respondsToSelector:selector]) {
return [[UIDevice currentDevice] performSelector:selector];
}
}
return [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];
}
로는 iOS6 ★★★★★★★★★★★★★★★★★★★★★★★★★★★.NSUUID
RFC4122에 준거한 클래스
Apple 링크: NSUID의 apple_ref
iOS 11에서는 Device Check 프레임워크가 도입되었습니다.디바이스를 일의로 식별하기 위한 완전한 솔루션을 갖추고 있습니다.
UDID를 취득하는 효과적인 방법:
- 앱 내에서 웹 서버를 시작합니다. 하나는 특수하게 조작된 MobileConfiguration 프로파일을 반환하고 다른 하나는 UDID를 수집해야 합니다.자세한 내용은 이쪽, 이쪽, 이쪽.
- Mobile Safari의 첫 페이지를 앱 내부에서 열면 Settings.app으로 리디렉션되어 구성 프로파일을 설치하도록 요청됩니다.프로파일을 설치하면 UDID가 두 번째 웹 페이지로 전송되고 앱 내부에서 액세스할 수 있습니다(Settings.app에는 필요한 모든 사용 권한과 다양한 샌드박스 규칙이 있습니다).
import UIKit
import RoutingHTTPServer
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var bgTask = UIBackgroundTaskInvalid
let server = HTTPServer()
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
application.openURL(NSURL(string: "http://localhost:55555")!)
return true
}
func applicationDidEnterBackground(application: UIApplication) {
bgTask = application.beginBackgroundTaskWithExpirationHandler() {
dispatch_async(dispatch_get_main_queue()) {[unowned self] in
application.endBackgroundTask(self.bgTask)
self.bgTask = UIBackgroundTaskInvalid
}
}
}
}
class HTTPServer: RoutingHTTPServer {
override init() {
super.init()
setPort(55555)
handleMethod("GET", withPath: "/") {
$1.setHeader("Content-Type", value: "application/x-apple-aspen-config")
$1.respondWithData(NSData(contentsOfFile: NSBundle.mainBundle().pathForResource("udid", ofType: "mobileconfig")!)!)
}
handleMethod("POST", withPath: "/") {
let raw = NSString(data:$0.body(), encoding:NSISOLatin1StringEncoding) as! String
let plistString = raw.substringWithRange(Range(start: raw.rangeOfString("<?xml")!.startIndex,end: raw.rangeOfString("</plist>")!.endIndex))
let plist = NSPropertyListSerialization.propertyListWithData(plistString.dataUsingEncoding(NSISOLatin1StringEncoding)!, options: .allZeros, format: nil, error: nil) as! [String:String]
let udid = plist["UDID"]!
println(udid) // Here is your UDID!
$1.statusCode = 200
$1.respondWithString("see https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/iPhoneOTAConfiguration/ConfigurationProfileExamples/ConfigurationProfileExamples.html")
}
start(nil)
}
}
, 다음은 '보다 낫다'의 입니다.udid.mobileconfig
:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PayloadContent</key>
<dict>
<key>URL</key>
<string>http://localhost:55555</string>
<key>DeviceAttributes</key>
<array>
<string>IMEI</string>
<string>UDID</string>
<string>PRODUCT</string>
<string>VERSION</string>
<string>SERIAL</string>
</array>
</dict>
<key>PayloadOrganization</key>
<string>udid</string>
<key>PayloadDisplayName</key>
<string>Get Your UDID</string>
<key>PayloadVersion</key>
<integer>1</integer>
<key>PayloadUUID</key>
<string>9CF421B3-9853-9999-BC8A-982CBD3C907C</string>
<key>PayloadIdentifier</key>
<string>udid</string>
<key>PayloadDescription</key>
<string>Install this temporary profile to find and display your current device's UDID. It is automatically removed from device right after you get your UDID.</string>
<key>PayloadType</key>
<string>Profile Service</string>
</dict>
</plist>
프로파일 설치는 실패하지만(예상된 응답을 구현하지 않았습니다. 설명서를 참조하십시오) 앱은 올바른 UDID를 얻을 수 있습니다.그리고 mobile config에 서명해야 합니다.
Swift 3.0의 경우 아래 코드를 사용하십시오.
let deviceIdentifier: String = (UIDevice.current.identifierForVendor?.uuidString)!
NSLog("output is : %@", deviceIdentifier)
사용할 수 있습니다.
NSString *sID = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];
이는 모든 어플리케이션에서 디바이스에 대해 고유합니다.
애플은 iOS 11에 DeviceCheck라고 불리는 새로운 프레임워크를 추가했는데, 이것은 여러분이 고유 식별자를 매우 쉽게 얻을 수 있도록 도와줄 것입니다.자세한 내용은 이 양식을 참조하십시오.https://medium.com/ @httposhbotre01/http-identifier-for-ios-http-590bb778290d
만약 누군가가 대안을 찾을 때 이 질문을 우연히 발견한다면.에서 이 접근방식을 따르고 있습니다.IDManager
solutionsclass의 입니다. 이것은 다른 솔루션에서 가져온 컬렉션입니다.Key Chain Util은 Key Chain Util을 사용합니다. 이 경우에도 하실 수 있습니다.hashed MAC address
츠키노
/* Apple confirmed this bug in their system in response to a Technical Support Incident
request. They said that identifierForVendor and advertisingIdentifier sometimes
returning all zeros can be seen both in development builds and apps downloaded over the
air from the App Store. They have no work around and can't say when the problem will be fixed. */
#define kBuggyASIID @"00000000-0000-0000-0000-000000000000"
+ (NSString *) getUniqueID {
if (NSClassFromString(@"ASIdentifierManager")) {
NSString * asiID = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];
if ([asiID compare:kBuggyASIID] == NSOrderedSame) {
NSLog(@"Error: This device return buggy advertisingIdentifier.");
return [IDManager getUniqueUUID];
} else {
return asiID;
}
} else {
return [IDManager getUniqueUUID];
}
}
+ (NSString *) getUniqueUUID {
NSError * error;
NSString * uuid = [KeychainUtils getPasswordForUsername:kBuyassUser andServiceName:kIdOgBetilngService error:&error];
if (error) {
NSLog(@"Error geting unique UUID for this device! %@", [error localizedDescription]);
return nil;
}
if (!uuid) {
DLog(@"No UUID found. Creating a new one.");
uuid = [IDManager GetUUID];
uuid = [Util md5String:uuid];
[KeychainUtils storeUsername:USER_NAME andPassword:uuid forServiceName:SERVICE_NAME updateExisting:YES error:&error];
if (error) {
NSLog(@"Error getting unique UUID for this device! %@", [error localizedDescription]);
return nil;
}
}
return uuid;
}
/* NSUUID is after iOS 6. */
+ (NSString *)GetUUID
{
CFUUIDRef theUUID = CFUUIDCreate(NULL);
CFStringRef string = CFUUIDCreateString(NULL, theUUID);
CFRelease(theUUID);
return [(NSString *)string autorelease];
}
#pragma mark - MAC address
// Return the local MAC addy
// Courtesy of FreeBSD hackers email list
// Last fallback for unique identifier
+ (NSString *) getMACAddress
{
int mib[6];
size_t len;
char *buf;
unsigned char *ptr;
struct if_msghdr *ifm;
struct sockaddr_dl *sdl;
mib[0] = CTL_NET;
mib[1] = AF_ROUTE;
mib[2] = 0;
mib[3] = AF_LINK;
mib[4] = NET_RT_IFLIST;
if ((mib[5] = if_nametoindex("en0")) == 0) {
printf("Error: if_nametoindex error\n");
return NULL;
}
if (sysctl(mib, 6, NULL, &len, NULL, 0) < 0) {
printf("Error: sysctl, take 1\n");
return NULL;
}
if ((buf = malloc(len)) == NULL) {
printf("Error: Memory allocation error\n");
return NULL;
}
if (sysctl(mib, 6, buf, &len, NULL, 0) < 0) {
printf("Error: sysctl, take 2\n");
free(buf); // Thanks, Remy "Psy" Demerest
return NULL;
}
ifm = (struct if_msghdr *)buf;
sdl = (struct sockaddr_dl *)(ifm + 1);
ptr = (unsigned char *)LLADDR(sdl);
NSString *outstring = [NSString stringWithFormat:@"%02X:%02X:%02X:%02X:%02X:%02X", *ptr, *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4), *(ptr+5)];
free(buf);
return outstring;
}
+ (NSString *) getHashedMACAddress
{
NSString * mac = [IDManager getMACAddress];
return [Util md5String:mac];
}
+ (NSString *)md5String:(NSString *)plainText
{
if(plainText == nil || [plainText length] == 0)
return nil;
const char *value = [plainText UTF8String];
unsigned char outputBuffer[CC_MD5_DIGEST_LENGTH];
CC_MD5(value, strlen(value), outputBuffer);
NSMutableString *outputString = [[NSMutableString alloc] initWithCapacity:CC_MD5_DIGEST_LENGTH * 2];
for(NSInteger count = 0; count < CC_MD5_DIGEST_LENGTH; count++){
[outputString appendFormat:@"%02x",outputBuffer[count]];
}
NSString * retString = [NSString stringWithString:outputString];
[outputString release];
return retString;
}
+ (NSString *) getUniqueUUID {
NSError * error;
NSString * uuid = [KeychainUtils getPasswordForUsername:kBuyassUser andServiceName:kIdOgBetilngService error:&error];
if (error) {
NSLog(@"Error geting unique UUID for this device! %@", [error localizedDescription]);
return nil;
}
if (!uuid) {
DLog(@"No UUID found. Creating a new one.");
uuid = [IDManager GetUUID];
uuid = [Util md5String:uuid];
[KeychainUtils storeUsername:USER_NAME andPassword:uuid forServiceName:SERVICE_NAME updateExisting:YES error:&error];
if (error) {
NSLog(@"Error getting unique UUID for this device! %@", [error localizedDescription]);
return nil;
}
}
return uuid;
}
ios7에서는 identifierForVendor를 사용할 수 있습니다.
-(NSString*)uniqueIDForDevice
{
NSString* uniqueIdentifier = nil;
if( [UIDevice instancesRespondToSelector:@selector(identifierForVendor)] ) { // >=iOS 7
uniqueIdentifier = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
} else { //<=iOS6, Use UDID of Device
CFUUIDRef uuid = CFUUIDCreate(NULL);
//uniqueIdentifier = ( NSString*)CFUUIDCreateString(NULL, uuid);- for non- ARC
uniqueIdentifier = ( NSString*)CFBridgingRelease(CFUUIDCreateString(NULL, uuid));// for ARC
CFRelease(uuid);
}
}
return uniqueIdentifier;
}
--중요사항 ---
UDID와 identifier For Vendor는 다릅니다.---
1.) On uninstalling and reinstalling the app identifierForVendor will change.
2.) The value of identifierForVendor remains the same for all the apps installed from the same vendor on the device.
3.) The value of identifierForVendor also changes for all the apps if any of the app (from same vendor) is reinstalled.
Apple은 iOS 7부터 모든 공개 API에서 UDID를 숨겼습니다. FFFF로 시작하는 UDID는 가짜 ID입니다.이전에 작동했던 "Send UDID" 앱을 더 이상 테스트 장치의 UDID 수집에 사용할 수 없습니다.(파악!)
UDID는 장치가 XCode(주최자 내)에 연결되어 있을 때, 장치가 iTunes에 연결되어 있을 때 표시됩니다(단, 식별자를 표시하려면 '시리얼 번호'를 클릭해야 합니다).
프로비저닝 프로파일에 추가할 디바이스의 UDID를 가져와야 하는데 XCode에서 직접 추가할 수 없는 경우 iTunes에서 복사/붙여넣기 절차를 안내해야 합니다.
PC/Mac에서 iTunes를 사용하지 않고 UDID를 취득할 수 있는 방법은 (iOS 7 출시 이후) 있습니까?
저도 몇 가지 문제가 있었습니다.해결 방법은 간단합니다.
// Get Bundle Info for Remote Registration (handy if you have more than one app)
NSString *appName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"];
NSString *appVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
// Get the users Device Model, Display Name, Unique ID, Token & Version Number
UIDevice *dev = [UIDevice currentDevice];
NSString *deviceUuid=[dev.identifierForVendor UUIDString];
NSString *deviceName = dev.name;
완벽하지는 않지만 UDID에 가장 가까운 대안 중 하나입니다(iOS 8.1 및 Xcode 6.1을 사용하는 Swift의 경우:
랜덤 UUID 생성
let strUUID: String = NSUUID().UUIDString
Keychain Wrapper 라이브러리를 사용합니다.
키 체인에 문자열 값을 추가합니다.
let saveSuccessful: Bool = KeychainWrapper.setString("Some String", forKey: "myKey")
키 체인에서 문자열 값을 가져옵니다.
let retrievedString: String? = KeychainWrapper.stringForKey("myKey")
키 체인에서 문자열 값을 삭제합니다.
let removeSuccessful: Bool = KeychainWrapper.removeObjectForKey("myKey")
이 솔루션은 키체인을 사용하기 때문에 앱을 제거하고 다시 설치한 후에도 키체인에 저장된 레코드는 유지됩니다.이 레코드를 삭제하려면 디바이스의 모든 콘텐츠와 설정을 리셋하는 방법밖에 없습니다.그래서 저는 이 대체 솔루션이 완벽하지는 않지만 Swift를 사용하여 iOS 8.1에서 UDID를 대체하는 최고의 솔루션 중 하나라고 언급했습니다.
NSLog(@"%@", [UIDevice current Device]IDForVendor]);
언급URL : https://stackoverflow.com/questions/6993325/uidevice-uniqueidentifier-deprecated-what-to-do-now
'sourcecode' 카테고리의 다른 글
TypeError를 극복하는 방법: 캐시할 수 없는 유형: '리스트' (0) | 2023.04.13 |
---|---|
Windows(v10)에서 Android Studio를 완전히 제거하려면 어떻게 해야 합니까? (0) | 2023.04.13 |
셸 명령 출력의 첫 줄을 가져옵니다. (0) | 2023.04.13 |
Git에서 SHA 해시에 의한 커밋으로 되돌리시겠습니까? (0) | 2023.04.13 |
Linux Bash에서 어레이에 LS를 할당하려면 어떻게 해야 합니까? (0) | 2023.04.13 |