1. Shared devices

When a device needs to be provided for other users to operate, the device can be shared with other users, and the user who receives the shared device can simply operate the device.

Class Name Description
TuyaSmartHomeDeviceShare Share device, get share info, manage share device

1.1. Add Device Share

1.1.1. Add Multiple Device Sharing (coverage)

Sharing multiple devices to users will override all previous user sharing

Declaration

-(void)addShareWithHomeId:homeId 
              countryCode:countryCode
              userAccount:userAccount 
                   devIds:(NSArray<NSString *> *) success
                  failure:(nullable TYFailureError)failure;

Parameters

Parameter Description
homeId device home id
countryCode share member country code
userAccount share member user account
devIds share device id list
success success callback
failure failure callback

Example

Objc:


- (void)addMemberShare {
    //self.deviceShare  = [[TuyaSmartHomeDeviceShare alloc] init];

    [self.deviceShare addShareWithHomeId:homeId countryCode:@"your_country_code" userAccount:@"user_account" devIds:(NSArray<NSString *> *) success:^(TuyaSmartShareMemberModel *model) {
        NSLog(@"addShare success");
    } failure:^(NSError *error) {
        NSLog(@"addShare failure: %@", error);
    }];
}

Swift:

func addMemberShare() {
    deviceShare?.add(withHomeId: homeId, countryCode: "your_country_code", userAccount: "user_account", devIds: ["devIds"], success: { (memberModel) in
        print("addShare success")
    }, failure: { (error) in
        if let e = error {
            print("addShare failure: \(e)")
        }
    })
}

1.1.2. Add Shares (new, not overwriting old Shares)

Sharing multiple devices to users will add the devices to all user shareing

Declaration

- (void)addShareWithMemberId:(NSInteger)memberId
                      devIds:(NSArray <NSString *> *)devIds
                     success:(TYSuccessHandler)success
                     failure:(TYFailureError)failure;

Parameters

Parameter Description
memberId share user member id
success success callback
failure failure callback

Example

Objc:


- (void)addMemberShare {
    //self.deviceShare  = [[TuyaSmartHomeDeviceShare alloc] init];

    [self.deviceShare addShareWithMemberId:memberId devIds:(NSArray<NSString *> *) success:^{
        NSLog(@"addShare success");
    } failure:^(NSError *error) {
        NSLog(@"addShare failure: %@", error);
    }];
}

Swift:

func addMemberShare() {
    deviceShare?.add(withMemberId: memberId, devIds: ["devIds"], success: {
        print("addShare success")
    }, failure: { (error) in
        if let e = error {
            print("addShare failure: \(e)")
        }
    })
}

1.1.3. Device Add Sharing

Sharing device to users will add the devices to all user shareing

Declaration

- (void)addDeviceShareWithHomeId:(long long)homeId
                     countryCode:(NSString *)countryCode
                     userAccount:(NSString *)userAccount
                           devId:(NSString *)devId
                         success:(void(^)(TuyaSmartShareMemberModel *model))success
                         failure:(TYFailureError)failure;

Parameters

Parameter Description
homeId device home id
countryCode share member country code
userAccount share member account
devId share device id
success success callback
failure failure callback

Example

Objc:


- (void)addDeviceShare {
     //self.deviceShare  = [[TuyaSmartHomeDeviceShare alloc] init];

    [self.deviceShare addDeviceShareWithHomeId:homeId countryCode:@"country_code" userAccount:@"user_account" devId:@"dev_id" success:^(TuyaSmartShareMemberModel *model) {

        NSLog(@"addDeviceShare success");

    } failure:^(NSError *error) {

        NSLog(@"addDeviceShare failure: %@", error);

    }];

}

Swift:

func addDeviceShare() {
    deviceShare?.add(withHomeId: homeId, countryCode: "country_code", userAccount: "user_account", devId: "dev_id", success: { (model) in
        print("addDeviceShare success")
    }, failure: { (error) in
        if let e = error {
            print("addDeviceShare failure: \(e)")
        }
    })
}

1.2. Getting Shared Relationships

1.2.1. Get List of All Active Shared Users in the Home

Declaration

- (void)getShareMemberListWithHomeId:(long long)homeId
                             success:(void(^)(NSArray<TuyaSmartShareMemberModel *> *list))success
                             failure:(TYFailureError)failure;

Parameters

Parameter Description
homeId home id
success success callback
failure failure callback

Example

Objc:


- (void)getShareMemberList {
    //self.deviceShare  = [[TuyaSmartHomeDeviceShare alloc] init];

    [self.deviceShare getShareMemberListWithHomeId:homeId success:^(NSArray<TuyaSmartShareMemberModel *> *list)

        NSLog(@"getShareMemberList success");

    } failure:^(NSError *error) {

        NSLog(@"getShareMemberList failure: %@", error);

    }];

}

Swift:

func getShareMemberList() {
    deviceShare?.getMemberList(withHomeId: homeId, success: { (list) in
        print("getShareMemberList success")
    }, failure: { (error) in
        if let e = error {
            print("getShareMemberList failure: \(e)")
        }
    })
}

1.2.2. Get List of All Shared Uers Received

Declaration

- (void)getReceiveMemberListWithSuccess:(void(^)(NSArray<TuyaSmartShareMemberModel *> *list))success
                                failure:(TYFailureError)failure;

Parameters

Parameter Description
success success callback
failure failure callback

Example

Objc:


- (void)getReceiveMemberList {
    //self.deviceShare  = [[TuyaSmartHomeDeviceShare alloc] init];

    [self.deviceShare getReceiveMemberListWithSuccess:^(NSArray<TuyaSmartShareMemberModel *> *list) {

        NSLog(@"getReceiveMemberList success");

    } failure:^(NSError *error) {

        NSLog(@"getReceiveMemberList failure: %@", error);

    }];

}

Swift:

func getReceiveMemberList() {
    deviceShare?.getReceiveMemberList(success: { (list) in
        print("getReceiveMemberList success")
    }, failure: { (error) in
        if let e = error {
            print("getReceiveMemberList failure: \(e)")
        }
    })
}

1.2.3. Obtaining User-shared Data that is Actively Shared by a Single User

Declaration

- (void)getShareMemberDetailWithMemberId:(NSInteger)memberId
                                 success:(void(^)(TuyaSmartShareMemberDetailModel *model))success
                                 failure:(TYFailureError)failure;

Parameters

Parameter Description
memberId share member id
success success callback
failure failure callback

Example

Objc:


- (void)getShareMemberDetail {
     //self.deviceShare  = [[TuyaSmartHomeDeviceShare alloc] init];

    [self.deviceShare getShareMemberDetailWithMemberId:memberId success:^(TuyaSmartShareMemberDetailModel *model) {

        NSLog(@"getShareMemberDetail success");

    } failure:^(NSError *error) {

        NSLog(@"getShareMemberDetail failure: %@", error);

    }];

}

Swift:

func getShareMemberDetail() {
    deviceShare?.getMemberDetail(withMemberId: memberId, success: { (model) in
        print("getShareMemberDetail success")
    }, failure: { (error) in
        if let e = error {
            print("getShareMemberDetail failure: \(e)")
        }
    })
}

1.2.4. Getting Shared Data from a Single Recipient

Declaration

- (void)getReceiveMemberDetailWithMemberId:(NSInteger)memberId
                                   success:(void(^)(TuyaSmartReceiveMemberDetailModel *model))success
                                   failure:(TYFailureError)failure;

Parameters

Parameter Description
memberId recipient member id
success success callback
failure failure callback

Example

Objc:


- (void)getReceiveMemberDetail {
    //self.deviceShare  = [[TuyaSmartHomeDeviceShare alloc] init];

    [self.deviceShare getReceiveMemberDetailWithMemberId:memberId success:^(TuyaSmartReceiveMemberDetailModel *model) {

        NSLog(@"getReceiveMemberDetail success");

    } failure:^(NSError *error) {

        NSLog(@"getReceiveMemberDetail failure: %@", error);

    }];

}

Swift:

func getReceiveMemberDetail() {
    deviceShare?.getReceiveMemberDetail(withMemberId: memberId, success: { (model) in
        print("getReceiveMemberDetail success")
    }, failure: { (error) in
        if let e = error {
            print("getReceiveMemberDetail failure: \(e)")
        }
    })
}

1.2.5. Get a Single Device Shared User List

Declaration

- (void)getDeviceShareMemberListWithDevId:(NSString *)devId
                                  success:(void(^)(NSArray<TuyaSmartShareMemberModel *> *list))success
                                  failure:(TYFailureError)failure;

Parameters

Parameter Description
devId device id
success success callback
failure failure callback

Example

Objc:


- (void)getDeviceShareMemberList {
     //self.deviceShare  = [[TuyaSmartHomeDeviceShare alloc] init];

    [self.deviceShare getDeviceShareMemberListWithDevId:@"dev_id" success:^(NSArray<TuyaSmartShareMemberModel *> *list) {

        NSLog(@"getDeviceShareMemberList success");

    } failure:^(NSError *error) {

        NSLog(@"getDeviceShareMemberList failure: %@", error);

    }];

}

Swift:

func getDeviceShareMemberList() {
    deviceShare?.getMemberList(withDevId: "dev_id", success: { (model) in
        print("getDeviceShareMemberList success")
    }, failure: { (error) in
        if let e = error {
            print("getDeviceShareMemberList failure: \(e)")
        }
    })
}

1.2.6. Who Shares Access Devices

Declaration

- (void)getShareInfoWithDevId:(NSString *)devId
                      success:(void(^)(TuyaSmartReceivedShareUserModel *model))success
                      failure:(TYFailureError)failure;

Parameters

Parameter Description
devId receive share device id
success success callback
failure failure callback

Example

Objc:


- (void)getShareInfo {
     //self.deviceShare  = [[TuyaSmartHomeDeviceShare alloc] init];

     [self.deviceShare getShareInfoWithDevId:@"dev_id" success:^(TuyaSmartReceivedShareUserModel *model) {

        NSLog(@"get shareInfo success");

    } failure:^(NSError *error) {

        NSLog(@"get shareInfo failure: %@", error);

    }];

}

Swift:

func getShareInfo() {
    deviceShare?.getInfoWithDevId("dev_id", success: { (model) in
        print("getShareInfo success")
    }, failure: { (error) in
        if let e = error {
            print("getShareInfo failure: \(e)")
        }
    })
}

1.3. Remove Sharing

1.3.1. Delete Active Sharers

The sharer deletes all shared relationships with this user through memberId (user dimension delete)

Declaration

- (void)removeShareMemberWithMemberId:(NSInteger)memberId
                              success:(TYSuccessHandler)success
                              failure:(TYFailureError)failure;

Parameters

Parameter Description
memberId share memer id
success success callback
failure failure callback

Example

Objc:


- (void)removeShareMember {
     //self.deviceShare  = [[TuyaSmartHomeDeviceShare alloc] init];

    [self.deviceShare removeShareMemberWithMemberId:memberId success:^{

        NSLog(@"removeShareMember success");

    } failure:^(NSError *error) {

        NSLog(@"removeShareMember failure: %@", error);

    }];

}

Swift:

func removeShareMember() {
    deviceShare?.removeMember(withMemberId: memberId, success: {
        print("removeShareMember success")
    }, failure: { (error) in
        if let e = error {
            print("removeShareMember failure: \(e)")
        }
    })
}

1.3.2. Delete Receiving Sharer

The shared party obtains the information of all shared devices of this user through memberId

Declaration

- (void)removeReceiveShareMemberWithMemberId:(NSInteger)memberId
                                     success:(TYSuccessHandler)success
                                     failure:(TYFailureError)failure;

Parameters

Parameter Description
memberId revice share member id
success success callback
failure failure callback

Example

Objc:


- (void)removeReceiveMember {
     //self.deviceShare  = [[TuyaSmartHomeDeviceShare alloc] init];

    [self.deviceShare removeReceiveShareMemberWithMemberId:memberId success:^{

        NSLog(@"removeReceiveMember success");

    } failure:^(NSError *error) {

        NSLog(@"removeReceiveMember failure: %@", error);

    }];

}

Swift:

func removeReceiveMember() {
    deviceShare?.removeReceiveMember(withMemberId: memberId, success: {
        print("removeReceiveMember success")
    }, failure: { (error) in
        if let e = error {
            print("removeReceiveMember failure: \(e)")
        }
    })
}

1.3.3. Single Device Remove Sharing

Declaration

- (void)removeDeviceShareWithMemberId:(NSInteger)memberId
                                devId:(NSString *)devId
                              success:(TYSuccessHandler)success
                              failure:(TYFailureError)failure;

Parameters

Parameter Description
memberId share member id
devId share device id
success success callback
failure failure callback

Example

Objc:


- (void)removeDeviceShare {
     //self.deviceShare  = [[TuyaSmartHomeDeviceShare alloc] init];

    [self.deviceShare removeDeviceShareWithMemberId:memberId devId:@"dev_id" success:^{

        NSLog(@"removeDeviceShare success");

    } failure:^(NSError *error) {

        NSLog(@"removeDeviceShare failure: %@", error);

    }];

 }

Swift:

func removeDeviceShare() {
    deviceShare?.remove(withMemberId: memberId, devId: "dev_id", success: {
        print("removeDeviceShare success")
    }, failure: { (error) in
        if let e = error {
            print("removeDeviceShare failure: \(e)")
        }
    })
}

1.3.4. Remove Shared Devices Received

Declaration

- (void)removeReceiveDeviceShareWithDevId:(NSString *)devId
                                  success:(TYSuccessHandler)success
                                  failure:(TYFailureError)failure;

Parameters

Parameter Description
devId reviced device id
success success callback
failure failure callback

Example

Objc:


- (void)removeDeviceShare {
     //self.deviceShare  = [[TuyaSmartHomeDeviceShare alloc] init];

    [self.deviceShare removeReceiveDeviceShareWithDevId:@"dev_id" success:^{

        NSLog(@"removeDeviceShare success");

    } failure:^(NSError *error) {

        NSLog(@"removeDeviceShare failure: %@", error);

    }];

}

Swift:

func removeDeviceShare() {
    deviceShare?.removeReceive(withDevId: "dev_id", success: {
        print("removeDeviceShare success")
    }, failure: { (error) in
        if let e = error {
            print("removeDeviceShare failure: \(e)")
        }
    })
}

1.4. Modify Note Name

1.4.1. Modify the nickname of the active sharer

Declaration

- (void)renameShareMemberNameWithMemberId:(NSInteger)memberId
                                     name:(NSString *)name
                                  success:(TYSuccessHandler)success
                                  failure:(TYFailureError)failure;

Parameters

Parameter Description
memberId share member id
name new name
success success callback
failure failure callback

Example

Objc:


- (void)updateShareMemberName {
     //self.deviceShare  = [[TuyaSmartHomeDeviceShare alloc] init];

    [self.deviceShare renameShareMemberNameWithMemberId:memberId name:@"new_name" success:^{

        NSLog(@"updateShareMemberName success");

    } failure:^(NSError *error) {

        NSLog(@"updateShareMemberName failure: %@", error);

    }];

Swift:

func updateShareMemberName() {
    deviceShare?.renameShareMemberName(withMemberId: "memberId", name: "new_name", success: {
        print("updateShareMemberName success")
    }, failure: { (error) in
        if let e = error {
            print("updateShareMemberName failure: \(e)")
        }
    })
}

1.4.2. Modify the Nickname of the Recipient Sharer

Declaration

- (void)renameReceiveShareMemberNameWithMemberId:(NSInteger)memberId
                                            name:(NSString *)name
                                         success:(TYSuccessHandler)success
                                         failure:(TYFailureError)failure;

Parameters

Parameter Description
memberId revice share member id
name new name
success success callback
failure failure callback

Example

Objc:


- (void)updateReceiveMemberName {
     //self.deviceShare  = [[TuyaSmartHomeDeviceShare alloc] init];

    [self.deviceShare renameReceiveShareMemberNameWithMemberId:memberId name:@"new_name" success:^{

        NSLog(@"updateReceiveMemberName success");

    } failure:^(NSError *error) {

        NSLog(@"updateReceiveMemberName failure: %@", error);

    }];

}

Swift:

func updateReceiveMemberName() {
    deviceShare?.renameReceiveMemberName(withMemberId: memberId, name: "new_name", success: {
        print("updateReceiveMemberName success")
    }, failure: { (error) in
        if let e = error {
            print("updateReceiveMemberName failure: \(e)")
        }
    })
}

results matching ""

    No results matching ""