Skip to content

Commit 3ffb97a

Browse files
committed
add setbadge api
1 parent 458e864 commit 3ffb97a

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

src/ios/Plugins/JMessagePlugin.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,5 @@
8080
- (void)getChatRoomConversationList:(CDVInvokedUrlCommand *)command;
8181
- (void)getChatRoomOwner:(CDVInvokedUrlCommand *)command;
8282

83+
- (void)setBadge:(CDVInvokedUrlCommand *)command;
8384
@end

src/ios/Plugins/JMessagePlugin.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2343,4 +2343,12 @@ - (void)getChatRoomOwner:(CDVInvokedUrlCommand *)command {
23432343
}];
23442344
}
23452345

2346+
2347+
- (void)setBadge:(CDVInvokedUrlCommand *)command {
2348+
NSDictionary * param = [command argumentAtIndex:0];
2349+
2350+
if (param[@"badge"]) {
2351+
[JMessage setBadge:[param[@"badge"] integerValue]];
2352+
}
2353+
}
23462354
@end

www/JMessagePlugin.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,18 @@ var JMessagePlugin = {
106106
logout: function () {
107107
exec(null, null, PLUGIN_NAME, 'userLogout', [])
108108
},
109+
/**
110+
* 设置 JMessage 服务器角标。
111+
* @param {object} params = {
112+
* badge: number
113+
* }
114+
*/
115+
setBadge: function (params) {
116+
if (device.platform !== 'Android') {
117+
exec(null, null, PLUGIN_NAME, 'setBadge', [params])
118+
}
119+
120+
},
109121
/**
110122
* 登录成功则返回用户信息,未登录则对应用户信息为空对象。
111123
*

0 commit comments

Comments
 (0)