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

Response#

Parameter NameType
dataUserRelation?
errorGenericError?
PurchaseClient.createUserIdRelation("masterUserId")    .then((userRelation) => {        console.log('Relation created.\nMaster UserID: ' + userRelation.masterUser + '\nSlave UserID: ' + userRelation.slaveUser);    })    .catch((error) => {        console.log(error.message)    });

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

Response#

Parameter NameType
successboolean
errorGenericError?
PurchaseClient.deleteSubUserIdRelation("subUserId")      .then((success) => {          console.log('Deletion is ' + success ? 'successful' : 'not successful');      })      .catch((error) => {          console.log(error.message)      });

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

Response#

Parameter NameType
successbool
errorGenericError?
PurchaseClient.deleteMasterUserIdRelation("masterUserId")      .then((success) => {          console.log('Deletion is ' + success ? 'successful' : 'not successful');      })      .catch((error) => {          console.log(error.message)      });

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

displaying_products_1displaying_products_1