How to get unique device id in iOS

skyshine picture skyshine · Sep 1, 2016 · Viewed 14.1k times · Source

I am working on iOS app for push notification feature i need to send unique device id of iOS device to server ,in android secure androd id getting for every device,is there any way to get unique device id of iOS. I found some answers vendor id and ad id are they unique

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

Answer

iSashok picture iSashok · Sep 1, 2016

For get UUID you can use this code

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

But for push notifications you need device token and it will create after user will accept permission and UIApplication delegate method will call

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