setAppBadge
Description
info
Set App unread count badge, used to display unread count badge during offline push.
Note
Currently only effective for firebase.
- iOS
- Flutter
- uni-app
- React-Native
Function Prototype
Future setAppBadge(int count, {
String? operationID,
});
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| count | int | Yes | Badge count |
Return Result
| Parameter Name | Parameter Type | Description |
|---|---|---|
| then | void | Success callback |
| onError | Function | Failure callback |
Code Example
OpenIM.iMManager.messageManager.setAppBadge();
Function Prototype
- (void)setAppBadge:(NSInteger)count
onSuccess:(nullable OIMSuccessCallback)onSuccess
onFailure:(nullable OIMFailureCallback)onFailure;
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| count | NSInteger | Yes | Badge count |
Return Result
| Name | Type | Description |
|---|---|---|
| onSuccess | OIMSuccessCallback | Success return |
| onFailure | OIMFailureCallback | Failure return |
Code Example
[OIMManager.manager setAppBadge:0
onSuccess:^(NSString * _Nullable data) {
} onFailure:^(NSInteger code, NSString * _Nullable msg) {
}];
Parameter Details
Parameter Details
Function Prototype
IMSDK.asyncApi('setAppBadge', operationID: string, badge: number): Promise<void>
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| operationID | string | Yes | Operation ID, used to pinpoint issues, keep unique, prefer time+random |
| badge | number | Yes | Badge count |
Return Result
Use the
openim-uniapp-polyfillpackage to make the function Promise. When calling, you need to usethenandcatchto determine and handle success and failure callbacks.
| Parameter Name | Parameter Type | Description |
|---|---|---|
| Promise.then() | Promise<void> | Success callback |
| Promise.catch() | Promise<CatchResponse> | Failure callback |
Code Example
import IMSDK from 'openim-uniapp-polyfill';
IMSDK.asyncApi('setAppBadge', IMSDK.uuid(), 99)
.then(() => {
// Call successful
})
.catch(({ errCode, errMsg }) => {
// Call failed
});
Function Prototype
OpenIMSDK.setAppBadge(appUnreadCount: number, operationID?: string): Promise<void>
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| badge | number | Yes | Badge count |
| operationID | string | No | Operation ID, used to pinpoint issues, keep unique, prefer time+random |
Return Result
| Parameter Name | Parameter Type | Description |
|---|---|---|
| Promise.then() | Promise<void> | Success callback |
| Promise.catch() | Promise<OpenIMApiError> | Failure callback |
Code Example
import OpenIMSDK from "@openim/rn-client-sdk";
OpenIMSDK.setAppBadge(99)
.then(() => {
// Call successful
})
.catch((error) => {
// Call failed
});