Skip to content

Commit 4b26731

Browse files
committed
update iOS_API.md
1 parent df4bd67 commit 4b26731

File tree

2 files changed

+73
-58
lines changed

2 files changed

+73
-58
lines changed

example/documents/iOS_API.md

Lines changed: 38 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,68 +2,65 @@
22

33
All apis can find in jpush-react-native/index.js.
44

5-
- setBadge(badge, cb)
5+
- setBadge(Int, Function)
66

77
设置 badge 值
8-
```
8+
```javascript
99
JPushModule.setBadge(5, (success) => {
1010
console.log(success)
1111
});
1212
```
13-
14-
- setLocalNotification( date,
15-
textContain, // date
16-
badge, // int
17-
alertAction, // String
18-
notificationKey, // String
19-
userInfo, // Dictionary
20-
soundName // String
13+
- setLocalNotification
14+
```javascript
15+
setLocalNotification( Date, // date 触发本地推送的时间
16+
textContain, // String 推送消息体内容
17+
badge, // int 本地推送触发后 应用 Badge(小红点)显示的数字
18+
alertAction, // String 弹框的按钮显示的内容(IOS 8默认为"打开", 其他默认为"启动")
19+
notificationKey, // String 本地推送标示符
20+
userInfo, // Object 推送的附加字段 (任意键值对)
21+
soundName // String 自定义通知声音,设置为 null 为默认声音
2122
)
2223

2324
设置本地推送
2425
```
26+
```javascript
2527
JPushModule.setLocalNotification( this.state.date,
2628
this.state.textContain,
2729
5,
28-
'dfsa',
29-
'dfaas',
30-
null,
30+
'Action',
31+
'notificationIdentify',
32+
{myInfo: ""},
3133
null);
3234
```
3335

3436
## 事件
35-
监听 `ReceiveNotification` 事件,收到到推送的时候会回调
36-
```
37-
var subscription = NativeAppEventEmitter.addListener(
38-
'ReceiveNotification',
39-
(notification) => console.log(notification)
40-
);
41-
```
37+
- addOpenNotificationLaunchAppListener(Function)
4238

43-
监听 `OpenNotificationToLaunchApp` 事件,点击推送**启动 App **的时候会触发这个事件
39+
监听:应用没有启动的状态点击推送打开应用
4440

45-
```
46-
var subscription = NativeAppEventEmitter.addListener(
47-
'OpenNotificationToLaunchApp',
48-
(notification) => console.log(notification)
49-
);
50-
```
41+
```javascript
42+
JPushModule.addOpenNotificationLaunchAppListener( (notification) => {
43+
44+
})
45+
```
5146

47+
- removeOpenNotificationLaunchAppListener(Function)
5248

49+
取消监听:应用没有启动的状态点击推送打开应用,和 `addOpenNotificationLaunchAppListener` 成对使用
5350

54-
监听 `OpenNotification` 事件,点击推送的时候会执行这个回调(注意:iOS10 才开始触发这个事件)
51+
5552

56-
```
57-
var subscription = NativeAppEventEmitter.addListener(
58-
'OpenNotification',
59-
(notification) => console.log(notification)
60-
);
61-
```
6253

63-
监听 `networkDidReceiveMessage` 事件,收到 JPush 应用内消息会执行这个回调
64-
```
65-
var subscription = NativeAppEventEmitter.addListener(
66-
'networkDidReceiveMessage',
67-
(message) => console.log(message)
68-
);
69-
```
54+
- addnetworkDidLoginListener(Function)
55+
56+
监听:应用连接已登录,setTag 和 setAlias 相关操作需要在这个事件触发后才能起作用
57+
58+
```javascript
59+
JPushModule.addnetworkDidLoginListener( () => {
60+
61+
})
62+
```
63+
64+
- removenetworkDidLoginListener(Function)
65+
66+
取消监听:应用连接已登录,和 `addnetworkDidLoginListener` 成对使用

index.js

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,48 +53,59 @@ export default class JPush {
5353
}
5454

5555
/**
56-
* Android
56+
* Android Only
5757
*/
5858
static stopPush() {
5959
JPushModule.stopPush();
6060
}
6161

6262
/**
63-
* Android
63+
* Android Only
6464
*/
6565
static resumePush() {
6666
JPushModule.resumePush();
6767
}
6868

69+
/**
70+
* Android Only
71+
*
72+
* @param {Function} cb
73+
*/
6974
static notifyJSDidLoad(cb) {
7075
JPushModule.notifyJSDidLoad((resultCode) => {
7176
cb(resultCode);
7277
});
7378
}
7479

7580
/**
76-
* Android
81+
* Android Only
7782
*/
7883
static clearAllNotifications() {
7984
JPushModule.clearAllNotifications();
8085
}
8186

8287
/**
83-
* Android
88+
* Android Only
8489
*/
8590
static clearNotificationById(id) {
8691
JPushModule.clearNotificationById(id);
8792
}
8893

8994
/**
90-
* Android
95+
* Android Only
9196
*/
9297
static getInfo(cb) {
9398
JPushModule.getInfo((map) => {
9499
cb(map);
95100
});
96101
}
97102

103+
/**
104+
* 获取当前连接状态
105+
* @param {Fucntion} cb = (Boolean) => {}
106+
* 如果连接状态变更为已连接返回 true
107+
* 如果连接状态变更为断开连接连接返回 false
108+
*/
98109
static getConnectionState(cb) {
99110
JPushModule.getConnectionState((state) => {
100111
cb(state);
@@ -230,7 +241,7 @@ export default class JPush {
230241
}
231242

232243
/**
233-
* Android
244+
* Android Only
234245
*/
235246
static setStyleBasic() {
236247
JPushModule.setStyleBasic();
@@ -258,7 +269,7 @@ export default class JPush {
258269
}
259270

260271
/**
261-
* 监听自定义消息后事件
272+
* 监听:自定义消息后事件
262273
* @param {Function} cb = (Object) => { }
263274
*/
264275
static addReceiveCustomMsgListener(cb) {
@@ -269,7 +280,7 @@ export default class JPush {
269280
}
270281

271282
/**
272-
* 取消监听自定义消息后事件
283+
* 取消监听:自定义消息后事件
273284
* @param {Function} cb = (Object) => { }
274285
*/
275286
static removeReceiveCustomMsgListener(cb) {
@@ -282,6 +293,7 @@ export default class JPush {
282293

283294
/**
284295
* iOS Only
296+
* 监听:应用没有启动的状态点击推送打开应用
285297
* @param {Function} cb = (notification) => {}
286298
*/
287299
static addOpenNotificationLaunchAppListener(cb) {
@@ -293,6 +305,7 @@ export default class JPush {
293305

294306
/**
295307
* iOS Only
308+
* 取消监听:应用没有启动的状态点击推送打开应用
296309
* @param {Function} cb = () => {}
297310
*/
298311
static removeOpenNotificationLaunchAppEventListener(cb) {
@@ -306,7 +319,7 @@ export default class JPush {
306319
/**
307320
* iOS Only
308321
*
309-
* 监听应用连接已登录
322+
* 监听:应用连接已登录
310323
* @param {Function} cb = () => {}
311324
*/
312325
static addnetworkDidLoginListener(cb) {
@@ -319,7 +332,7 @@ export default class JPush {
319332
/**
320333
* iOS Only
321334
*
322-
* 取消监听应用连接已登录
335+
* 取消监听:应用连接已登录
323336
* @param {Function} cb = () => {}
324337
*/
325338
static removenetworkDidLoginListener(cb) {
@@ -331,7 +344,7 @@ export default class JPush {
331344
}
332345

333346
/**
334-
* 监听接收推送事件
347+
* 监听:接收推送事件
335348
* @param {} cb = (Object)=> {}
336349
*/
337350
static addReceiveNotificationListener(cb) {
@@ -342,7 +355,7 @@ export default class JPush {
342355
}
343356

344357
/**
345-
* 取消监听接收推送事件
358+
* 取消监听:接收推送事件
346359
* @param {Function} cb = (Object)=> {}
347360
*/
348361
static removeReceiveNotificationListener(cb) {
@@ -354,7 +367,7 @@ export default class JPush {
354367
}
355368

356369
/**
357-
* 监听点击推送事件
370+
* 监听:点击推送事件
358371
* @param {Function} cb = (Object)=> {}
359372
*/
360373
static addReceiveOpenNotificationListener(cb) {
@@ -365,7 +378,7 @@ export default class JPush {
365378
}
366379

367380
/**
368-
* 取消监听点击推送事件
381+
* 取消监听:点击推送事件
369382
* @param {Function} cb = (Object)=> {}
370383
*/
371384
static removeReceiveOpenNotificationListener(cb) {
@@ -400,7 +413,7 @@ export default class JPush {
400413
}
401414

402415
/**
403-
* 监听连接状态变更
416+
* 监听:连接状态变更
404417
* @param {Function} cb = (Boolean) => { }
405418
* 如果连接状态变更为已连接返回 true
406419
* 如果连接状态变更为断开连接连接返回 false
@@ -412,6 +425,12 @@ export default class JPush {
412425
});
413426
}
414427

428+
/**
429+
* 监听:连接状态变更
430+
* @param {Function} cb = (Boolean) => { }
431+
* 如果连接状态变更为已连接返回 true
432+
* 如果连接状态变更为断开连接连接返回 false
433+
*/
415434
static removeConnectionChangeListener(cb) {
416435
if (!listeners[cb]) {
417436
return;
@@ -422,7 +441,7 @@ export default class JPush {
422441

423442

424443
/**
425-
*
444+
* 获取 RegistrationId
426445
* @param {Function} cb = (String) => { }
427446
*/
428447
static getRegistrationID(cb) {
@@ -450,7 +469,6 @@ export default class JPush {
450469
});
451470
}
452471

453-
454472
/**
455473
* iOS Only
456474
* 设置本地推送

0 commit comments

Comments
 (0)