setAppBadge
Feature Introduction
Note
Set badge count.
Attention
Currently, only effective for Firebase.
- iOS
- Flutter
- uni-app
- React-Native
Function Prototype
Future setAppBadge(int count, {
String? operationID,
});
Input Parameters
Parameter Name | Data Type | Mandatory | Description |
---|---|---|---|
count | int | Yes | Badge count |
Return Result
Parameter Name | Data 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 | Data Type | Mandatory | Description |
---|---|---|---|
count | NSInteger | Yes | Badge count |
Return Result
Name | Data 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 | Data Type | Mandatory | Description |
---|---|---|---|
operationID | string | Yes | Operation ID, for problem identification, recommended to use current time and random number |
badge | number | Yes | Badge count |
Return Result
With the
openim-uniapp-polyfill
package, the function is made into a Promise. Usethen
andcatch
to determine and handle successful and failed callbacks respectively.
Parameter Name | Data 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((data) => {
// Successful call
})
.catch(({ errCode, errMsg }) => {
// Failed call
});
Function Prototype
OpenIMSDKRN.setAppBadge(appUnreadCount: number, operationID: string): Promise<void>
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
badge | number | Yes | Badge count |
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.setAppBadge(99, 'operationID')
.then((data) => {
// Successful call
})
.catch(({ errCode, errMsg }) => {
// Failed call
});