From 9c103753e61297c96b6b591a2cc9aae61d870b9e Mon Sep 17 00:00:00 2001 From: huangminlinux <380108184@qq.com> Date: Tue, 12 Dec 2017 14:20:04 +0800 Subject: [PATCH] update iOS docs --- doc/iOS_API.md | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/doc/iOS_API.md b/doc/iOS_API.md index c1b5ee9..1650521 100644 --- a/doc/iOS_API.md +++ b/doc/iOS_API.md @@ -143,7 +143,7 @@ window.JPush.getRegistrationID(function(data) { #### event - jpush.openNotification -点击通知启动或唤醒应用程序时会触发该事件 +点击通知(包括 localNotification 和 remoteNotification)启动或唤醒应用程序时会触发该事件 #### 代码示例 @@ -433,6 +433,34 @@ window.JPush.clearAllLocalNotifications() 监听 `jpush.receiveLocalNotification` 事件获取,「App 在后台时点击通知横幅」或「App 在前台时收到」均会触发该事件。 +#### 代码示例 + +- 在你需要接收通知的的 js 文件中加入: + +```js +document.addEventListener("jpush.receiveLocalNotification", onLocalNotification, false) +``` + +- onLocalNotification 需要这样写: + +```js +var onLocalNotification = function(event) { + alert("receive Local Notification:" + JSON.stringify(event)) +} +``` + +- event 举例 + +```json +{ + badge = 1; + content = "Hello JPush"; + extras = { + "__JPUSHNotificationKey" = notificationIdentify_1; + }; +} +``` + ### iOS 10 收到本地通知 监听 [jpush.receiveNotification](#前台收到推送)、[jpush.openNotification](点击推送通知),获取推送内容后,通过获取到的 `__JPUSHNotificationKey` 字段([本地通知](#本地通知) 设置的 `notificationID`)来判断是本地通知,并处理。