|
12 | 12 | - [接收推送事件](#接收推送事件) |
13 | 13 | - [接收自定义消息事件](#接收自定义消息事件) |
14 | 14 | - [iOS Only API](#ios-only-api) |
| 15 | + - [setupPush](#setuppush) |
15 | 16 | - [setBadge](#setbadge) |
16 | 17 | - [getBadge](#getbadge) |
17 | 18 | - [setLocalNotification](#setlocalnotification) |
@@ -133,21 +134,26 @@ Android 和 iOS 通用 API。 |
133 | 134 | - sendLocalNotification(notification) |
134 | 135 |
|
135 | 136 | - **buildId** : Number // 设置通知样式,1 为基础样式,2 为自定义样式。自定义样式需要先调用 setStyleCustom 接口设置自定义样式。(Android Only) |
| 137 | +<<<<<<< HEAD |
136 | 138 | - **id** : Number // 通知的 id, 可用于取消通知 |
137 | 139 | - **title** : String // 通知标题 |
138 | 140 | - **content** : String // 通知内容 |
| 141 | +======= |
| 142 | + - **id** : Number // 通知的 id, 可用于取消通知 |
| 143 | + - **title** : String // 通知标题 |
| 144 | + - **content** : String // 通知内容 |
| 145 | +>>>>>>> 57b24382bb295d08dbb0f1275ebfc3880fe2d9b9 |
139 | 146 | - **extra** : Object // extra 字段 |
140 | 147 | - **fireTime** : Number // 通知触发时间的时间戳(毫秒) |
141 | 148 | - **badge** : Number // 本地推送触发后应用角标的 badge 值 (iOS Only) |
142 | | - - **soundName** : String // 指定推送的音频文件 (iOS Only) |
| 149 | + - **sound** : String // 指定推送的音频文件 (iOS Only) |
143 | 150 | - **subtitle** : String // 子标题 (iOS10+ Only) |
144 | 151 |
|
145 | 152 | ```javascript |
146 | 153 | var currentDate = new Date() |
147 | 154 | JPushModule.sendLocalNotification( |
148 | 155 | { |
149 | 156 | id:5, |
150 | | - title:'haha', |
151 | 157 | content:'content', |
152 | 158 | extra:{key1:'value1',key2:'value2'}, |
153 | 159 | fireTime: currentDate.getTime() + 3000, |
@@ -214,31 +220,38 @@ Android 和 iOS 通用 API。 |
214 | 220 | - removeReceiveCustomMsgListener(function) |
215 | 221 |
|
216 | 222 | ``` |
217 | | - JPushModule.removeReceiveCustomMsgListener(callback); |
| 223 | + JPushModule.removeReceiveCustomMsgListener(callback); |
218 | 224 | ``` |
219 | 225 |
|
220 | 226 |
|
221 | 227 |
|
222 | 228 | ### iOS Only API |
223 | 229 |
|
| 230 | +#### setupPush |
| 231 | + |
| 232 | +调用这个接口会向系统注册推送功能(会弹出推送权限请求),注意使用自动配置会自动在 `AppDeletate.m` 插入注册代码如下,如果不希望在应用启动的时候就向用户申请权限可以删掉这部分代码。 |
| 233 | + |
| 234 | +```objective-c |
| 235 | +// AppDelegate.m 自动插入的代码 |
| 236 | +JPUSHRegisterEntity * entity = [[JPUSHRegisterEntity alloc] init]; |
| 237 | +entity.types = UNAuthorizationOptionAlert|UNAuthorizationOptionBadge|UNAuthorizationOptionSound; |
| 238 | +[JPUSHService registerForRemoteNotificationConfig:entity delegate:self]; |
| 239 | +``` |
| 240 | +
|
224 | 241 | #### setBadge |
225 | 242 |
|
226 | 243 | 设置应用 badge 值,该方法还会同步 JPush 服务器的的 badge 值,JPush 服务器的 badge 值用于推送 badge 自动 +1 时会用到。 |
227 | 244 |
|
228 | 245 | ```js |
229 | | - JPushModule.setBadge(5, (success) => { |
230 | | - console.log(success) |
231 | | - }); |
| 246 | + JPushModule.setBadge(5, (success) => {} ); |
232 | 247 | ``` |
233 | 248 |
|
234 | 249 | #### getBadge |
235 | 250 |
|
236 | 251 | 获取应用 badge 值。 |
237 | 252 |
|
238 | 253 | ```javascript |
239 | | - JPushModule.getBadge((badge) => { |
240 | | - console.log(badge) |
241 | | - }); |
| 254 | + JPushModule.getBadge((badge) => { } ); |
242 | 255 | ``` |
243 | 256 |
|
244 | 257 | #### setLocalNotification |
@@ -279,21 +292,21 @@ setLocalNotification( Date, // date 触发本地推送的时间 |
279 | 292 | JPushModule.addOpenNotificationLaunchAppListener(callback) |
280 | 293 | ``` |
281 | 294 |
|
282 | | -- removeOpenNotificationLaunchAppListener(function) |
| 295 | +- removeOpenNotificationLaunchAppEventListener(function) |
283 | 296 |
|
284 | 297 | ```javascript |
285 | | - JPushModule.removeOpenNotificationLaunchAppListener(callback) |
| 298 | + JPushModule.removeOpenNotificationLaunchAppEventListener(callback) |
286 | 299 | ``` |
287 | 300 |
|
288 | | - 取消监听:`removeOpenNotificationLaunchAppListener` 取消事件回调,和`addOpenNotificationLaunchAppListener` 方法成对使用。 |
| 301 | + 取消监听:`removeOpenNotificationLaunchAppEventListener` 取消事件回调,和`addOpenNotificationLaunchAppListener` 方法成对使用。 |
289 | 302 |
|
290 | 303 | **Network Did Login Event** |
291 | 304 |
|
292 | 305 | **NOTE **: iOS 需要安装到 [email protected]+ 。 |
293 | 306 |
|
294 | 307 | - addnetworkDidLoginListener(function) |
295 | 308 |
|
296 | | - 添加回调:添加网络已经等了事件回调 ,`setTag` 和 `setAlias` 需要在网络已经登录成功后调用才会有效 。 |
| 309 | + 添加回调:添加网络已登录事件回调 ,`setTag` 和 `setAlias` 需要在网络已经登录成功后调用才会有效 。 |
297 | 310 |
|
298 | 311 | ```javascript |
299 | 312 | var callback = () => { |
|
0 commit comments