Skip to content

Commit 7e4a9dc

Browse files
KenChoiKenChoi
authored andcommitted
update docs
1 parent 65516ab commit 7e4a9dc

File tree

2 files changed

+324
-4
lines changed

2 files changed

+324
-4
lines changed

example/documents/APIs.md

Lines changed: 160 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,22 @@
1717
- [Open Notification Launch App Event](#Open Notification Launch App Event)
1818
- [Network Did Login Event](#Network Did Login Event)
1919
- [Android Only API:](Android Only API)
20-
-
20+
- [initPush](#initPush)
21+
- [stopPush](#stopPush)
22+
- [resumePush](#resumePush)
23+
- [crashLogOFF](#crashLogOFF)
24+
- [crashLogON](#crashLogON)
25+
- [notifyJSDidLoad](#notifyJSDidLoad)
26+
- [clearAllNotifications](#clearAllNotifications)
27+
- [clearNotificationById](#clearNotificationById)
28+
- [getInfo](#getInfo)
29+
- [setStyleBasic](#setStyleBasic)
30+
- [setStyleCustom](#setStyleCustom)
31+
- [setLatestNotificationNumber](#setLatestNotificationNumber)
32+
- [setSilenceTime](#setSilenceTime)
33+
- [setPushTime](#setPushTime)
34+
- [addGetRegistrationIdListener](#addGetRegistrationIdListener)
35+
- [removeGetRegistrationIdListener](#removeGetRegistrationIdListener)
2136

2237
Note: In Android, you must call initPush first, iOS doesn't need.
2338

@@ -230,5 +245,148 @@ setLocalNotification( Date, // date local notification fire data
230245
remove: JPush SDK did login event ,`removenetworkDidLoginListener` and `addnetworkDidLoginListener` used in pairs.
231246

232247

248+
### Android Only API
233249

234-
### Android Only API
250+
- #### initPush
251+
252+
Init JPush。Suggest invokes in `MainActivity` 's `onCreate` method:
253+
254+
```
255+
JPushInterface.init(this);
256+
```
257+
258+
- #### stopPush
259+
260+
Stop push. Suggest invokes in `MainActivity` 's `onStop` method:
261+
262+
```
263+
JPushInterface.onStop(this);
264+
```
265+
266+
- #### resumePush
267+
268+
Resume push. Suggest invokes in `MainActivity` 's `onResume` method:
269+
270+
```
271+
JPushInterface.onResume(this);
272+
```
273+
274+
- #### crashLogOFF
275+
276+
Stop upload crash log.
277+
278+
```
279+
JPushModule.crashLogOFF();
280+
```
281+
282+
- #### crashLogON
283+
284+
Start upload crash log.
285+
286+
```
287+
JPushModule.crashLogON();
288+
```
289+
290+
- #### notifyJSDidLoad
291+
292+
Notify JPushModule complete init,send cached events.
293+
294+
```
295+
JPushModule.notifyJSDidLoad((resultCode) => {
296+
297+
});
298+
```
299+
300+
- #### clearAllNotifications
301+
302+
Clear all notifications.
303+
304+
```
305+
JPushModule.clearAllNotifications();
306+
```
307+
308+
- #### clearNotificationById
309+
310+
Clear notification by id.
311+
312+
```
313+
JPushModule.clearNotificationById(id);
314+
```
315+
316+
- #### getInfo
317+
318+
Get device's infomation.
319+
320+
```
321+
JPushModule.getInfo((map) => {
322+
});
323+
```
324+
325+
- #### setStyleBasic
326+
327+
Set notification's style to basic style.
328+
329+
```
330+
JPushModule.setStyleBasic();
331+
```
332+
333+
- #### setStyleCustom
334+
335+
Set custom notification style. Need add custom xml file to Android resource.
336+
337+
```
338+
JPushModule.setStyleCustom();
339+
```
340+
341+
- #### setLatestNotificationNumber
342+
343+
Set latest number of notifications. Default will show 5 latest notifications.
344+
345+
```
346+
JPushModule.setLatestNotificationNumber(maxNumber);
347+
```
348+
349+
- #### setSilenceTime
350+
351+
Set silence push time, will not push during these time.
352+
353+
```
354+
/**
355+
* Android Only
356+
* @param {object} config = {"startTime": String, "endTime": String} // eg:{startTime: "20:30", endTime: "8:30"}
357+
*/
358+
JPushModule.setSilenceTime(config);
359+
```
360+
361+
- #### setPushTime
362+
363+
Set allow push time.
364+
365+
```
366+
/**
367+
* Android Only
368+
* @param {object} config = {"days": Array, "startHour": Number, "endHour": Number}
369+
* // eg:{days: [0, 6], startHour: 8, endHour: 23} indicate push is allowed in 8 a.m. to 23 p.m. in satuaday and sunday.
370+
*/
371+
JPushModule.setPushTime(config);
372+
```
373+
374+
375+
376+
- #### addGetRegistrationIdListener
377+
378+
If add this listener, when finished registering device, open app will invoke this callback.
379+
380+
```
381+
JPushModule.addGetRegistrationIdListener(cb)
382+
```
383+
384+
- #### removeGetRegistrationIdListener
385+
386+
Remove listener. `removeGetRegistrationIdListener` and `addGetRegistrationIdListener` should used in pairs.
387+
388+
```
389+
JPushModule.removeGetRegistrationIdListener(callback);
390+
```
391+
392+

example/documents/APIs_zh.md

Lines changed: 164 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,22 @@
1717
- [点击推送启动应用事件](#Open Notification Launch App Event)
1818
- [网络成功登陆事件](#Network Did Login Event)
1919
- [Android Only API:](Android Only API)
20-
-
20+
- [initPush](#initPush)
21+
- [stopPush](#stopPush)
22+
- [resumePush](#resumePush)
23+
- [crashLogOFF](#crashLogOFF)
24+
- [crashLogON](#crashLogON)
25+
- [notifyJSDidLoad](#notifyJSDidLoad)
26+
- [clearAllNotifications](#clearAllNotifications)
27+
- [clearNotificationById](#clearNotificationById)
28+
- [getInfo](#getInfo)
29+
- [setStyleBasic](#setStyleBasic)
30+
- [setStyleCustom](#setStyleCustom)
31+
- [setLatestNotificationNumber](#setLatestNotificationNumber)
32+
- [setSilenceTime](#setSilenceTime)
33+
- [setPushTime](#setPushTime)
34+
- [addGetRegistrationIdListener](#addGetRegistrationIdListener)
35+
- [removeGetRegistrationIdListener](#removeGetRegistrationIdListener)
2136

2237
注意: 在 Android 需要先调用 `initPush` 方法, iOS 端不需要。
2338

@@ -259,5 +274,152 @@ setLocalNotification( Date, // date 触发本地推送的时间
259274
移除回调:移除该回调 ,`removenetworkDidLoginListener` 取消事件回调,和 `addnetworkDidLoginListener` 方法成对使用。
260275

261276

277+
### Android Only API
262278

263-
### Android Only API
279+
- #### initPush
280+
281+
初始化 JPush。建议在 `MainActivity``onCreate` 中调用:
282+
283+
```
284+
JPushInterface.init(this);
285+
```
286+
287+
- #### stopPush
288+
289+
停止推送。建议在 `MainActivity``onStop` 中调用:
290+
291+
```
292+
JPushInterface.onStop(this);
293+
```
294+
295+
- #### resumePush
296+
297+
恢复推送。建议在 `MainActivity``onResume` 中调用:
298+
299+
```
300+
JPushInterface.onResume(this);
301+
```
302+
303+
- #### crashLogOFF
304+
305+
停止上报崩溃日志
306+
307+
```
308+
JPushModule.crashLogOFF();
309+
```
310+
311+
- #### crashLogON
312+
313+
开启上报崩溃日志
314+
315+
```
316+
JPushModule.crashLogON();
317+
```
318+
319+
- #### notifyJSDidLoad
320+
321+
通知 JPushModule 初始化完成,发送缓存事件。
322+
323+
```
324+
JPushModule.notifyJSDidLoad((resultCode) => {
325+
326+
});
327+
```
328+
329+
- #### clearAllNotifications
330+
331+
清除所有通知
332+
333+
```
334+
JPushModule.clearAllNotifications();
335+
```
336+
337+
- #### clearNotificationById
338+
339+
根据 notificationId 来清除通知
340+
341+
```
342+
JPushModule.clearNotificationById(id);
343+
```
344+
345+
- #### getInfo
346+
347+
获取设备信息
348+
349+
```
350+
JPushModule.getInfo((map) => {
351+
});
352+
```
353+
354+
- #### setStyleBasic
355+
356+
设置通知为基本样式
357+
358+
```
359+
JPushModule.setStyleBasic();
360+
```
361+
362+
- #### setStyleCustom
363+
364+
自定义通知样式,需要添加自定义 xml 样式。
365+
366+
```
367+
JPushModule.setStyleCustom();
368+
```
369+
370+
- #### setLatestNotificationNumber
371+
372+
设置展示最近通知的条数,默认展示 5 条。
373+
374+
```
375+
JPushModule.setLatestNotificationNumber(maxNumber);
376+
```
377+
378+
- #### setSilenceTime
379+
380+
设置静默推送时间
381+
382+
```
383+
/**
384+
* Android Only
385+
* @param {object} config = {"startTime": String, "endTime": String} // 例如:{startTime: "20:30", endTime: "8:30"}
386+
*/
387+
JPushModule.setSilenceTime(config);
388+
```
389+
390+
- #### setPushTime
391+
392+
设置允许推送时间
393+
394+
```
395+
/**
396+
* Android Only
397+
* @param {object} config = {"days": Array, "startHour": Number, "endHour": Number}
398+
* // 例如:{days: [0, 6], startHour: 8, endHour: 23} 表示星期天和星期六的上午 8 点到晚上 11 点都可以推送
399+
*/
400+
JPushModule.setPushTime(config);
401+
```
402+
403+
404+
405+
- #### addGetRegistrationIdListener
406+
407+
如果添加这个监听,设备注册成功后,打开应用将会回调这个事件。
408+
409+
```
410+
JPushModule.addGetRegistrationIdListener(cb)
411+
```
412+
413+
- #### removeGetRegistrationIdListener
414+
415+
移除监听 registrationId 事件,与 `addGetRegistrationIdListener` 成对使用。
416+
417+
```
418+
JPushModule.removeGetRegistrationIdListener(callback);
419+
```
420+
421+
422+
423+
424+
425+

0 commit comments

Comments
 (0)