Container
# Container
| API Name | Description |
|---|---|
| runtime.getVersion | Get terminal version number |
| runtime.getCurrentUser | Get current user information |
| runtime.requestAuthCode | Get temporary auth code for SSO |
| runtime.showUpdate | Show version update prompt |
# Get Terminal Version Number
Code Example
FSOpen.runtime.getVersion({
onSuccess: function(resp){
alert('Current terminal version: ' + resp.ver);
},
onFail: function(error){
alert('API call failed, error code: ' + error.errorCode);
}
});
Method: FSOpen.runtime.getVersion
JS Version: 2.0.0
Client Support: 5.4.0 and above
Success callback parameters:
| Parameter | Type | Description |
|---|---|---|
| ver | String | Version number, e.g. '5.3.0' |
# Get Current User Information
Code Example
FSOpen.runtime.getCurrentUser({
onSuccess: function(resp){
alert('Current user info: ' + JSON.stringify(resp));
},
onFail: function(error){
alert('API call failed, error code: ' + error.errorCode);
}
});
Method: FSOpen.runtime.getCurrentUser
JS Version: 2.0.0
Client Support: 5.4.0 and above
Success callback parameters:
| Parameter | Type | Description |
|---|---|---|
| user | Object | Current user details, see fields below |
user object parameters:
| Parameter | Type | Description |
|---|---|---|
| userId | String | User ID |
| nickname | String | User nickname |
| String | User email | |
| avatarUrl | String | User avatar URL |
| position | String | User position information |
# Get SSO Auth Code
The SSO auth code is mainly used to obtain user identity (user ID) through server APIs. Refer to User-level Authorization.
Code Example
FSOpen.runtime.requestAuthCode({
onSuccess: function(resp) {
alert('SSO auth code: ' + JSON.stringify(resp));
},
onFail: function(error) {
alert('API call failed, error code: ' + error.errorCode);
}
});
Method: FSOpen.runtime.requestAuthCode
JS Version: 2.0.0
Client Support: 5.4.0 and above
Success callback parameters:
| Parameter | Type | Description |
|---|---|---|
| code | String | SSO auth code for obtaining user identity |
The client also provides a more convenient JS API to directly get current user information. Please refer to the Get Current User Information API.
# Show Version Update Prompt
Displays an update prompt. On Android, users can click OK to directly jump to the app store for upgrade.
Code Example
FSOpen.runtime.showUpdate({
message: 'A new version is available.'
});
Method: FSOpen.runtime.showUpdate
JS Version: 2.0.0
Client Support: 5.4.0 and above
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| message | String | Yes | Update prompt message |