How to programmatically grant a user reader access to a Realm? (Swift iOS)

cloud

#1

I’m attempting to grant a user read access to an existing Realm.

The trouble I’m having is figuring out how to get the identity of the target user. I know the email address of the target user but I don’t know how to look up the user to retrieve the identity property.

let permission = SyncPermission(
                realmPath: realmPath,  // The remote Realm path on which to apply the changes
                identity: otherUserID, // The user ID for which these permission changes should be applied
                accessLevel: .read
            )   // The access level to be granted

#2

@anonymous9 You can use RLMSyncPermission and pass in the email:
https://realm.io/docs/objc/3.11.1/api/Classes/RLMSyncPermission.html


#3

You can also use the retrieve account method: