Anonymously Log In to an App with iCloud Apple ID - ios

According to this CloudKit overview:
CloudKit also enables your users to anonymously sign in to your apps with their iCloud Apple IDs without sharing their personal information.
I can't find anything else in their documentation about this capability. I already have an app with my own backend, so I wouldn't need any of the back-end-as-a-service features that CloudKit offers, but I would like to take advantage of logging a user in with their iCloud account, much the same way we currently do with Facebook and Twitter.
Is that possible with CloudKit, or do you also have to leverage their BAAS features in order to take advantage of login?

From what they discussed at WWDC, you'd do this using the fetchUserRecordIDWithCompletionHandler: method on CKContainer. That returns a CKRecordID that corresponds to the current user. This ID will be stable across devices but different for each app-- so if the same person uses your app on multiple devices, your app will get the same result everywhere, but other apps would get different results from yours.
Once you have the CKRecordID you can look up limited other user data (their name and email, I think) using fetchRecordWithID:completionHandler:. This request will trigger a permission alert to the user, so you only get it if they allow it.
This doesn't require you to use anything else in CloudKit. It does require that the user actually have an iCloud account configured on the device.

The permission alert will only pop if you call -[CKContainer requestApplicationPermission:CKApplicationPermissionUserDiscoverability...].
If the user grants permission (CKApplicationPermissionStatusGranted) then you can get the user's first and last name by running a CKDiscoverUserInfosOperation.
Requesting discoverability means that you can see the user's first and last name, and that any other user of the container can find their user record ID via an email address or look up their first and last name via a user record ID.

Related

Apple contact usage policy

I am building a native social app in Android and iOS
I am using contacts from users phonebook to determine if his target friends are on our app or not and send the events accordingly
I recently came across this news that Apple is banning apps to send contacts to the server, which is the backbone of my app in order to function
How should I approach this problem? How do apps like WhatsApp which sync contacts (whole phonebook) to their server manage through this?
Do I need apple review of the app to access phonebook permission?
From This article I quote
But the phone maker didn’t publicly mention updated App Store Review
Guidelines that now bar developers from making databases of address
book information they gather from iPhone users. Sharing and selling
that database with third parties is also now forbidden. And an app
can’t get a user’s contact list, say it’s being used for one thing,
and then use it for something else -- unless the developer gets
consent again. Anyone caught breaking the rules may be banned.
Since the question is quite general let's dive into it a bit.
Looking into the App Store Review Guidelines there are three places mentioning that users' contacts should not be collected.
First and second, users should not be forced to provide their address book in exchange for app functionality (paying with contacts; highlights were added, a similar phrase is used for app subscriptions):
Apps should allow a user to get what they’ve paid for without performing additional tasks, such as posting on social media, uploading contacts, […]
Third, uploading and/or storing contacts to/on a server has an impact on users' privacy and is prohibited for the following use-cases:
Do not use information from Contacts, Photos, or other APIs that access user data to build a contact database for your own use or for sale/distribution to third parties, and don’t collect information about which other apps are installed on a user’s device for the purposes of analytics or advertising/marketing.
This does not exclude using contacts for creating a social graph for the benefit of your users. However, collecting all contacts might violate the principle of data minimization. So Instead of just uploading all contacts, Apple recommends to use a contact picker (see ContactsUI), where the app only gets access to the contacts the user selected:
Data Minimization: Apps should only request access to data relevant to the core functionality of the app and should only collect and use data that is required to accomplish the relevant task. Where possible, use the out-of-process picker or a share sheet rather than requesting full access to protected resources like Photos or Contacts.
The Art. 32 of the GDPR requires you to take the
[…] the state of the art, the costs of implementation and the nature, scope, context and purposes of processing […]
into account.
I think that the process has to be made transparent (as in comprehensibly explained to the user):
The user should have control over which contacts are used for discovery. All would be a valid choice – selected contacts (through the contact picker) or manually entering contact information (phone number, email – whatever is used for your contact discovery process) would be valid choices as well.
The app should function even if the user denies access to the contacts. In that case you can still offer a contact picker, or manual entering.
You must describe the process, including what information is used and for what purpose, in your privacy policy.
You should at least hash the processed values, as you do not need the actual phone numbers or email addresses for contact discovery and hashing comes without much effort and cost. However, be aware that hashing of personally identifiable information is not sufficient for "anonymising" these values – which is a common misconception.
For more advanced protection, you can take a look at the blog post by the authors of the Signal app, where they describe technical details on how they protect their contact discovery process.

Is it possible to obtain an unique iCloud user ID on cocoa?

My iOS app is currently on beta in TestFlight, and as a way to retribute to the nice people who helped me test it I would like to offer them some goodies such as, for instance, the full final version of the app for free.
For this, I was thinking of sending them a last beta version which would, automatically and upon execution, store some kind of ID from the logged in user into a VIP list I would keep online and then every next version of the app would check for their ID in order to verify if the user is a VIP user and unlock all the premium features.
Is it possible to obtain in the Cocoa apis a unique identifier that is associated to the user (as opposed to the device unique identifier)? I want this because I want to recognise the user in whatever device he installs it. I would like to avoid having to make my beta testers manually register as VIPs.
Thanks!
Yes, this is possible using CloudKit. You'll need a CKContainer, and you'll ask it to fetch the user record ID. That record ID is unique for your apps, but is also stable for that user this means the same iCloud account will have the same record ID, regardless of which device they're running on or which of your apps they're using.
If you turn on the CloudKit capability for your project, Xcode will automatically create the iCloud container for you, and you can then access it using one of the two CKContainer constructors.

iCloud, iCloudKit, iOS 8, Apple id

As I understand it now can not get apple id in iOS 7.
iOS 8 has many edits to work with iCloud and adding iCloudKit. Will I be able to get Apple id from API and use it, for example, for registration in own server?
No, you cannot get the user's Apple ID.
What you can do with CloudKit is get an opaque user record ID. This object will be the same for the user for your app on all of their devices, but it will be different for other apps or other users. You can save that on your server and use it as something like a "log in with CloudKit" feature. This was described in the WWDC 2014 intro to CloudKit session. Basically, you use the fetchUserRecordIDWithCompletionHandler: method on CKContainer. But there's no way to link this to the Apple ID automatically-- you still need to ask the user if you want that.
Not that I am aware of. That's kind of "invading" the user's privacy because you'd be getting his Apple ID (which is an email) without his consent.
What I do, using Parse SDK, is to make the user log in anonimously at my Parse App, then save his automatically generated User ID in a iCloud Key-Value container. Whenever the user deletes the app and reinstalls it (or simply install in another device of his), my app knows that he has an username saved on iCloud and then uses that instead of creating a new user. This way, I get to keep track of my users without invading nobody's privacy.

adding users by contacts ios

I have an app where users create accounts by username and password. However, I also want users to be able to add friends via their mobile #. Is there a security reason as to why I would need to verify their number if my design goes as follows:
User A enters her # into app, which saves to database
User B gives app access to his contacts. User A is a contact in User B's address book. When the database is queried for all #'s in User B's contacts book, we find User A's # and User A is returned.
How could there be a security flaw if User A entered a false #?
That would definitely cause security issues. Of course, for an app like this, you would need some way to verify the data that you are receiving. What if one if the contacts phone numbers are wrong? Some phone numbers change all the time now and it would be difficult keeping up to date with them all.
But on a bigger note than that, I don't think this one would fly with Apple. I've never designed an app that needed to access more than one contact at a time and the user was fully aware of which contact he/she was importing to a database. But for an app to automatically upload multiple contacts from a users address book for intent to be stored on a remote database might cause security flags to be raised at Apple during the review process. So the app may never see light of day on the Apple Store.
If you really want to implement something similar, make sure users verify their phone number before use and instead of storing the users contacts on a server, just store the verified phone number. Then you can use the contacts in your phone to check mobile numbers that have been verified of other users and which ones have an account linked to them.

iCloud unique identifier

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!
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.
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.

Resources