Account - blockdate/ios-rn-sdk GitHub Wiki
用于获取当前用户信息,通过Service.account获取当前用户对象实例。
其中Service.account.ID可直接使用,其余属性需要使用Service.account.load().then()来进行获取,可参考下方Example。
具体的可用属性与方法请参考Interface -> IAccount类API说明。
IAccount不支持直接创建使用,如需使用请调用:
Service.account.load().then((info)=>{info 中各个字段才有值}}))
Export:
Example
import {Service} from 'miot'
console.log(Service.account.ID)
Service.account.load().then(account=>{
console.log(Service.account.nickName)
})-
miot/Account
-
~IAccount
-
.isLoaded :
boolean -
.ID :
string -
.nickName :
string -
.avatarURL :
string -
.birth :
string -
.email :
string -
.phone :
string -
.sex :
string -
.shareTime :
string -
.load(force) ⇒
Promise.<IAccount>
-
.isLoaded :
-
~IAccount
用户信息属性与方法说明
Kind: inner interface of miot/Account
Example
import {Service} from 'miot'
...
console.log(Service.account.ID)
if (Service.account.isLoaded) {
console.log(Service.account.nickName)
}else {
Service.account.load().then(account=>{
console.log(Service.account.nickName)
...
})
}
...-
~IAccount
-
.isLoaded :
boolean -
.ID :
string -
.nickName :
string -
.avatarURL :
string -
.birth :
string -
.email :
string -
.phone :
string -
.sex :
string -
.shareTime :
string -
.load(force) ⇒
Promise.<IAccount>
-
.isLoaded :
用户详情是否已经加载,不依赖于load方法。
如果已加载则所有属性可直接使用。
Kind: instance property of IAccount
Read only: true
当前登录账户userid,不依赖于load方法
Kind: instance property of IAccount
Read only: true
用户昵称,依赖于load方法
Kind: instance property of IAccount
Read only: true
用户头像的下载地址,依赖于load方法
Kind: instance property of IAccount
Read only: true
用户生日,依赖于load方法
Kind: instance property of IAccount
Read only: true
用户邮箱,依赖于load方法
Kind: instance property of IAccount
Read only: true
用户电话,依赖于load方法
Kind: instance property of IAccount
Read only: true
用户性别,依赖于load方法
Kind: instance property of IAccount
Read only: true
用户分享时间,依赖于load方法
Kind: instance property of IAccount
Read only: true
加载用户信息,所有依赖于load的用户信息需要在回调方法中会返回时才有值
Kind: instance method of IAccount
| Param | Type | Default | Description |
|---|---|---|---|
| force | boolean |
false |
强制刷新缓存,加载米家服务器的用户信息 |