User Relation
#
Create User RelationUserId 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.

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.
#
RequestParameter Name | Type |
---|---|
masterUserId | String |
completion | (CreateUserRelationResponse?, GenericError?) -> Void |
#
ResponseParameter Name | Type |
---|---|
response | CreateUserRelationResponse? |
error | GenericError? |
- Swift
- Objective-C
PurchaseClient.shared.createUserIdRelation(with: "masterUserId") { response, error in if let response = response { print(response) } else { print(error) }}
[[PurchaseClient shared] createUserIdRelationWith:@"masterUserId" completion:^(CreateUserRelationResponse * response, GenericError * error) { if (response != nil) { NSLog(@"%@", response); } else { NSLog(@"%@", error); }}];
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.
#
Delete User RelationIt'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.
#
RequestParameter Name | Type |
---|---|
subUserId | String |
completion | (DeleteUserRelationResponse?, GenericError?) -> Void |
#
ResponseParameter Name | Type |
---|---|
response | DeleteUserRelationResponse? |
error | GenericError? |
- Swift
- Objective-C
PurchaseClient.shared.deleteSubUserIdRelation(for: "subUserId") { result in switch result { case .success(let response): break case .failure(let error): break }}
[[PurchaseClient shared] deleteSubUserIdRelationFor:@"subUserId" completion:^(DeleteUserRelationResponse * response, GenericError * error) { if (response != nil) { NSLog(@"%@", response); } else { NSLog(@"%@", error); }}];
If you want to delete all the relationships related to the masterUserId, you can use deleteMasterUserIdRelation method by giving masterUserId as a parameter.
#
RequestParameter Name | Type |
---|---|
masterUserId | String |
completion | (DeleteUserRelationResponse?, GenericError?) -> Void |
#
ResponseParameter Name | Type |
---|---|
response | DeleteUserRelationResponse |
error | GenericError? |
- Swift
- Objective-C
PurchaseClient.shared.deleteMasterUserIdRelation(for: "masterUserId") { response, error in if let response = response { print(response) } else { print(error) }}
[[PurchaseClient shared] deleteMasterUserIdRelationFor:@"masterUserId" completion:^(DeleteUserRelationResponse * response, GenericError * error) { if (response != nil) { NSLog(@"%@", response); } else { NSLog(@"%@", error); }}];