Last Updated on : 2023-06-06 09:57:19download
A home owner can add an administrator and other members with lower permissions to the home. But the administrator can only add common members and other members with lower permissions to the home.
API description
The autoAccept
field of the MemberWrapperBean
object specifies whether an invitation is automatically accepted to add an invitee to the home. If the value is set to false
, you must call the processInvitation()
method, so the invitee needs to accept the invitation before joining the home.
void addMember(MemberWrapperBean memberWrapperBean, ITuyaDataCallback<MemberBean> callback)
Parameters
Parameter | Description |
---|---|
memberWrapperBean | The member information. |
Data model of MemberWrapperBean
Field | Type | Description |
---|---|---|
homeId | long | The ID of the home that the invitee joins. |
nickName | String | The nickname of the invitee. |
admin | boolean | Specifies whether the invitee is an administrator. |
memberId | long | The member ID of the invitee. |
headPic | String | The avatar of the invitee. If the value is set to nil , the invitee’s personal avatar is used. |
account | String | The account of the invitee. |
countryCode | String | The country code of the invitee’s account. |
invitationCode | String | The invitation code. |
role | int | The member role of the invitee. For more information, see the definition of MemberRole . |
autoAccept | boolean | Specifies whether the invitation is automatically accepted. Valid values:
|
Example
TuyaHomeSdk.getMemberInstance().addMember(memberWrapperBean, new ITuyaDataCallback<MemberBean>() {
@Override
public void onSuccess(MemberBean result) {
// do something
}
@Override
public void onError(String errorCode, String errorMessage) {
// do something
}
});
A home owner can remove an administrator and other members with lower permissions. The administrator can only remove common members and other members with lower permissions.
API description
The home will be processed in varied ways, depending on different values of memberId
:
memberId
is set to an administrator, common member, or custom role, the member to be removed will leave the home. In this case, the home will not be deleted and its devices will not be reset.memberId
is set to the home owner, the home is deleted and all devices of the home will be reset. The result is the same as that of dismissHome.void removeMember(long memberId, IResultCallback callback)
Parameters
Parameter | Description |
---|---|
memberId | The member ID. |
Example
TuyaHomeSdk.getMemberInstance().removeMember(memberId, new IResultCallback() {
@Override
public void onSuccess() {
// do something
}
@Override
public void onError(String code, String error) {
// do something
}
});
API description
void queryMemberList(long mHomeId, ITuyaGetMemberListCallback callback)
Parameters
Parameter | Description |
---|---|
mHomeId | The home ID. |
Example
TuyaHomeSdk.getMemberInstance().queryMemberList(mHomeId, new ITuyaGetMemberListCallback() {
@Override
public void onSuccess(List<MemberBean> memberBeans) {
// do something
}
@Override
public void onError(String errorCode, String error) {
// do something
}
});
API description (recommended)
void updateMember(MemberWrapperBean memberWrapperBean, IResultCallback callback)
Parameters
Parameter | Type | Description |
---|---|---|
memberWrapperBean | MemberWrapperBean | The member information. |
Example
TuyaHomeSdk.getMemberInstance().updateMember(memberWrapperBean, new IResultCallback() {
@Override
public void onSuccess() {
// do something
}
@Override
public void onError(String code, String error) {
// do something
}
});
API description (not recommended)
void updateMember(long memberId, String name, boolean admin, IResultCallback callback)
Parameters
Parameter | Type | Description |
---|---|---|
memberId | long | The member ID. |
name | name | The name of the member. |
admin | boolean | Specifies whether the member is an administrator. |
Example
TuyaHomeSdk.getMemberInstance().updateMember(memberId, name, admin, new IResultCallback() {
@Override
public void onSuccess() {
// do something
}
@Override
public void onError(String code, String error) {
// do something
}
});
API description
void getInvitationMessage(long homeId, ITuyaDataCallback callback)
Parameters
Parameter | Description |
---|---|
homeId | The home ID. |
Example
TuyaHomeSdk.getMemberInstance().getInvitationMessage(homeId, new ITuyaDataCallback<InviteMessageBean>() {
@Override
public void onSuccess(InviteMessageBean result) {
// onSuc
}
@Override
public void onError(String errorCode, String errorMessage) {
// onErr
}
});
API description
void joinHomeByInviteCode(String code, IResultCallback callback);
Parameters
Parameter | Description |
---|---|
code | The invitation code. |
Example
TuyaHomeSdk.getHomeManagerInstance().joinHomeByInviteCode("code" , new IResultCallback() {
@Override
public void onError(String code, String error) {
}
@Override
public void onSuccess() {
}
});
API description
void cancelMemberInvitationCode(long invitationId, IResultCallback callBack)
Parameters
Parameter | Description |
---|---|
invitationId | The invitation ID. |
Example
TuyaHomeSdk.getMemberInstance().cancelMemberInvitationCode(invitationId, new IResultCallback() {
@Override
public void onSuccess() {
// do something
}
@Override
public void onError(String code, String error) {
// do something
}
});
API description
void processInvitation(long homeId, boolean action, IResultCallback callBack)
Parameters
Parameter | Description |
---|---|
homeId | The home ID. |
action | Accepts or declines the invitation. |
Example
TuyaHomeSdk.getMemberInstance().processInvitation(homeId, action, new IResultCallback() {
@Override
public void onSuccess() {
// do something
}
@Override
public void onError(String code, String error) {
// do something
}
});
API description
void getInvitationList(long homeId, ITuyaDataCallback callback)
Parameters
Parameter | Description |
---|---|
homeId | The home ID. |
Example
TuyaHomeSdk.getMemberInstance().getInvitationList(homeId, new ITuyaDataCallback() {
@Override
public void onSuccess(List<InvitedMemberBean> memberBeans) {
// do something
}
@Override
public void onError(String errorCode, String error) {
// do something
}
});
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback