zohaibkhan
zohaibkhan

Reputation: 237

user's AppleId programmatically in iphone

is this possible to get the user's apple id which is currently login to device? Actually I implemented inapp purchases and I get a device id and Apple id of the user when it purchase the app.

Upvotes: 8

Views: 20692

Answers (7)

Yogesh Bangar
Yogesh Bangar

Reputation: 550

No you can't get Apple Id. Instead of that you could use identifierForVendor.

Objective-c:

[[UIDevice currentDevice] identifierForVendor]

Swift 3+:

UIDevice.current.identifierForVendor?.uuidString

If you want to read more about collecting user data check this out Apple Policy!

or you can use this (Swift 3):

UIDevice.current.identifierForVendor!.uuidString

For older versions:

UIDevice.currentDevice().identifierForVendor

or if you want a string:

UIDevice.currentDevice().identifierForVendor!.UUIDString

Upvotes: 1

Nikhil Jain
Nikhil Jain

Reputation: 3

ou can use this (Swift 3):

UIDevice.current.identifierForVendor!.uuidString For older versions:

UIDevice.currentDevice().identifierForVendor or if you want a string:

UIDevice.currentDevice().identifierForVendor!.UUIDString

Upvotes: 0

Kevin Machado
Kevin Machado

Reputation: 4187

No, you can't. It's a privacy element like the UDID.

You can read more about this here : Privacy issue

But, if you want, you can use the identifierForVendor provided by Apple using this method :

[[UIDevice currentDevice] identifierForVendor]

Upvotes: 2

iHulk
iHulk

Reputation: 4909

It's not possible. You can only retrieve the device's UDID. it's a privacy issue, just like their phone number. But you can get the certificate (Acknowledgement) for every purchase from apple server for a particular user.

Upvotes: 1

Gil Sand
Gil Sand

Reputation: 6040

Nope, you can't get that information. The only thing you can get are information from UIDevice (look it up on the apple doc) or a "fake UDID" (unique key that isn't the UDID) using [[UIDevice currentDevice] identifierForVendor], and the IP.

So you can identify your users in a unique way, but not get their information.

I really suggest you go browse the doc about the UIDevice, maybe you'll find something that you need there too

Upvotes: 0

Nurdin
Nurdin

Reputation: 23883

I'm not sure about apple id but you can grab device id programmatically. If you using hybrid app, you can using push phonegap plugin.

https://github.com/phonegap-build/PushPlugin

http://blog.revivalx.com/2014/08/29/implement-push-notifications-for-android-and-ios-phonegap-part-2/

For native

http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1

BTW, device id and UDID is a different thing.

Upvotes: 0

l0gg3r
l0gg3r

Reputation: 8954

No, it's not possible.
Instead of AppleId, you can use [[UIDevice currentDevice] identifierForVendor].

Upvotes: 6

Related Questions