Search code examples
ioscloudkit

How would you set info about iCloud user who has not yet started App?


Even dow client knows logged in user's friend e-mail address, client can not flag his friend i.e. if user's friend starts to use App can not treat him differently. Because discoverUserInfoWithEmailAddress method requires The user must already have run the app. Client can not get and edit user record from CloudKit to take a note there.

How would you preset some info about latter joining iCloud user?


Solution

  • You could create a 'Friends' record type which has at least a field for the email address and an optional userid field (reference type). For everybody that has installed the app you can create an record in this 'Friends' table including the recordId of that user. If you do want to friend someone that has not yet installed the app, then you would add him to your Friends without an userId.

    You could then also have different functionality for those Friends. For instance you could only invite them to use the app. The next time you start up the app you could check if there are new people that have installed the app. If that user is in the 'Friends' table, you could add it's userId or do some special action.

    What you also could do when a new user installs your app is to check if that user was added as a Friend by someone else. You could then send a message to that user notifying that the app was installed.