Skip to main content

User Relation

Create User Relation#

UserId is needed to make sure the purchase status appmate is tracking gets associated with the user you defined. You can also define relationships between different userIds. For example, you have a user who has two devices and he/she wants to use your app with both of them. If your user has some purchases that made with the first userId, also second userId will be able to see this products as purchased. Whenever there is a change in a user's entitlement to products within your app, the second device user also will be able to get this updates. It's easy to use this feature with appmate only by establishing relationships between the users.

master_sub_users

Here masterUserId is a userId value which you will relate with the current UserId.

Current userId is the value that you set with setUserId() method of PurchaseClient or the given parameter when creating an instance of PurchaseClient.

As you create a relationship between this masterUserId and current userId values, you can assume currentUserId as a subUserId here.

Request#

Parameter NameType
masterUserIdString
listenerReceivedDataListener<UserRelation, GenericError>

Response#

Parameter NameType
onSucceededUserRelation
onFailedGenericError
PurchaseClient.instance.createUserIdRelation(masterUserId,    object : ReceivedDataListener<UserRelation, GenericError> {       override fun onSucceeded(data: UserRelation) {       }       override fun onError(error: GenericError) {       }    })

Delete User Relation#

It's also possible to delete a relationship between the users. By giving subUserId as a parameter, you can use deleteSubUserIdRelation method and delete a relationship between subUserId and its master.

Request#

Parameter NameType
subUserIdString
listenerReceivedDataListener<Boolean, GenericError>

Response#

Parameter NameType
onSucceededBoolean
onFailedGenericError
PurchaseClient.instance.deleteSubUserIdRelation(subUserId,    object : ReceivedDataListener<Boolean, GenericError> {       override fun onSucceeded(data: Boolean) {       }       override fun onError(error: GenericError) {       }    })

If you want to delete all the relationships related to the masterUserId, you can use deleteMasterUserIdRelation method by giving masterUserId as a parameter.

Request#

Parameter NameType
masterUserIdString
listenerReceivedDataListener<Boolean, GenericError>

Response#

Parameter NameType
onSucceededBoolean
onFailedGenericError
PurchaseClient.instance.deleteMasterUserIdRelation(masterUserId,    object : ReceivedDataListener<Boolean, GenericError> {       override fun onSucceeded(data: UserRelation) {       }       override fun onError(error: GenericError) {       }    })

With this feature the same user of our app, will be able to reach active purchase results by using your application installed both two devices.

displaying_products_1displaying_products_1