3

I'm trying to learn about iCloud. I've read that there's ubiquityIdentityToken and it's used to determine if iCloud is available or if the user changed the account signed in. Also, this is only available in ios 6+

But what i need to know is the unique data for every iCloud user. What i'm saying is, after the user logs into iCloud, is there a way for us developers to know who that persons is/who the account belongs to like a username or id (similar to Facebook's fbid/identiferForVendor)? Could we even get the iCloud account of the user in code?

The reason why I want to know this is because i want to check if it's possible to use the user's iCloud account(or whatever unique data we could get from them) as the user's unique identifier on our server.

I hope I could get some answers. Thank you so much!

cessmestreet
  • 2,298
  • 3
  • 22
  • 42

2 Answers2

1

You can use CKContainer.fetchUserRecordID(completionHandler:)

Returns the user record ID associated with the current user.

https://developer.apple.com/documentation/cloudkit/ckcontainer/1399191-fetchuserrecordid

This article shows example of practical usage of record ID retrieved in this way: Onboarding without Signup Screens.

Vlad
  • 6,402
  • 1
  • 60
  • 74
0

Apple don't want you to do this. That is why they give you a unique token that is opaque. You can't use it as an id on your server. Apple do not allow iTunes accounts to be used in that way at this point in time.

I suggest you use your own account names, or you use accounts from Facebook or Twitter, which are accessible via system APIs on iOS.

Drew McCormack
  • 3,490
  • 1
  • 19
  • 23
  • I cannot agree. Since the token can be encoded and stored as NSData, where exactly does Apple prohibit us from identifying user via this token? – lef Mar 07 '14 at 15:42
  • It's not that they prohibit it, it's that it is not documented to be the same on each device (as far as I know). So you can try it, but it may not work, or it may break at any time. – Drew McCormack Mar 08 '14 at 16:08