setAppBackgroundStatus
Function Introduction
Description
Set whether the application is running in the background. Call when the application switches between foreground and background status.
- uni-app
- Browser/Electron/MiniProgram
- React-Native
- Unity
Function Prototype
IMSDK.setAppBackgroundStatus(isBackgroud: boolean, operationID?: string): Promise<WsResponse>
Input Parameters
Parameter Name | Parameter Type | Required | Description |
---|---|---|---|
isBackgroud | boolean | Yes | Whether the application is running in the background |
Return Results
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<WsResponse> | Successful callback |
Promise.catch() | Promise<WsResponse> | Failure callback |
Code Example
import { getSDK } from 'open-im-sdk-wasm';
const IMSDK = getSDK();
// use in electron with ffi
// import { getWithRenderProcess } from '@openim/electron-client-sdk/lib/render';
// const { instance: IMSDK } = getWithRenderProcess();
// use in mini program
// import { OpenIMSDK } from 'open-im-sdk';
// const IMSDK = new OpenIMSDK();
IMSDK.setAppBackgroundStatus(true)
.then(() => {
// Successful call
})
.catch(({ errCode, errMsg }) => {
// Failed call
});
Function Prototype
IMSDK.asyncApi('setAppBackgroundStatus', operationID: string, isBackgroud: boolean): Promise<void>
Input Parameters
Parameter Name | Parameter Type | Required | Description |
---|---|---|---|
operationID | string | Yes | Operation ID, used for problem tracking. Recommended to use the current time combined with a random number |
isBackgroud | boolean | Yes | Whether the application is running in the background |
Return Results
The function is Promise-ified using the
openim-uniapp-polyfill
package. When calling, usethen
andcatch
to judge and handle success and failure callbacks.
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<void> | Successful callback |
Promise.catch() | Promise<CatchResponse> | Failure callback |
Code Example
import IMSDK from 'openim-uniapp-polyfill';
IMSDK.asyncApi('setAppBackgroundStatus', IMSDK.uuid(), true)
.then(() => {
// Successful call
})
.catch(({ errCode, errMsg }) => {
// Failed call
});
Function Prototype
OpenIMSDKRN.setAppBackgroundStatus(isBackground: boolean, operationID: string): Promise<void>
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
isBackgroud | boolean | Yes | Whether the application is running in the background |
operationID | string | Yes | Operation ID, used for problem location, keep unique, suggest using current time and random number |
Return Result
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<void> | Callback on successful call |
Promise.catch() | Promise<CatchResponse> | Callback on failed call |
Code Example
import OpenIMSDKRN from "open-im-sdk-rn";
OpenIMSDKRN.setAppBackgroundStatus(true, 'operationID');
.then(() => {
// Successful call
})
.catch(({ errCode, errMsg }) => {
// Failed call
});
Function Prototype
public static void SetAppBackGroundStatus(bool isBackGround, OnSucOrError cb)
Input Parameter
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
isBackgroud | bool | Yes | Whether the application is running in the background |
cb | OnSucOrError | Yes | Callback |
Return Result
Code Example
IMSDK.SetAppBackGroundStatus(true,(suc,errCode,errMsg)=>{
});