|
1 | | -## jpush-react-native iOS API |
2 | | - |
3 | | -All apis can find in jpush-react-native/index.js. |
4 | | - |
5 | | -- setBadge(badge, cb) |
6 | | - |
7 | | -设置 badge 值 |
8 | | -``` |
9 | | -JPushModule.setBadge(5, (success) => { |
10 | | - console.log(success) |
11 | | -}); |
12 | | -``` |
13 | | - |
14 | | -- setLocalNotification( date, |
15 | | - textContain, // date |
16 | | - badge, // int |
17 | | - alertAction, // String |
18 | | - notificationKey, // String |
19 | | - userInfo, // Dictionary |
20 | | - soundName // String |
21 | | - ) |
22 | | - |
23 | | -设置本地推送 |
24 | | -``` |
25 | | - JPushModule.setLocalNotification( this.state.date, |
26 | | - this.state.textContain, |
27 | | - 5, |
28 | | - 'dfsa', |
29 | | - 'dfaas', |
30 | | - null, |
31 | | - null); |
32 | | -``` |
33 | | - |
34 | | -## 事件 |
35 | | -监听 `ReceiveNotification` 事件,收到到推送的时候会回调 |
36 | | -``` |
37 | | -var subscription = NativeAppEventEmitter.addListener( |
38 | | - 'ReceiveNotification', |
39 | | - (notification) => console.log(notification) |
40 | | -); |
41 | | -``` |
42 | | - |
43 | | -监听 `OpenNotification` 事件,点击推送的时候会执行这个回调 |
44 | | -``` |
45 | | -var subscription = NativeAppEventEmitter.addListener( |
46 | | - 'OpenNotification', |
47 | | - (notification) => console.log(notification) |
48 | | -); |
49 | | -``` |
50 | | - |
51 | | -监听 `networkDidReceiveMessage` 事件,收到 JPush 应用内消息会执行这个回调 |
52 | | -``` |
53 | | -var subscription = NativeAppEventEmitter.addListener( |
54 | | - 'networkDidReceiveMessage', |
55 | | - (message) => console.log(message) |
56 | | -); |
57 | | -``` |
| 1 | +## jpush-react-native iOS API |
| 2 | + |
| 3 | +All apis can find in jpush-react-native/index.js. |
| 4 | + |
| 5 | +- setBadge(badge, cb) |
| 6 | + |
| 7 | +设置 badge 值 |
| 8 | +``` |
| 9 | +JPushModule.setBadge(5, (success) => { |
| 10 | + console.log(success) |
| 11 | +}); |
| 12 | +``` |
| 13 | + |
| 14 | +- setLocalNotification( date, |
| 15 | + textContain, // date |
| 16 | + badge, // int |
| 17 | + alertAction, // String |
| 18 | + notificationKey, // String |
| 19 | + userInfo, // Dictionary |
| 20 | + soundName // String |
| 21 | + ) |
| 22 | + |
| 23 | +设置本地推送 |
| 24 | +``` |
| 25 | + JPushModule.setLocalNotification( this.state.date, |
| 26 | + this.state.textContain, |
| 27 | + 5, |
| 28 | + 'dfsa', |
| 29 | + 'dfaas', |
| 30 | + null, |
| 31 | + null); |
| 32 | +``` |
| 33 | + |
| 34 | +## 事件 |
| 35 | +监听 `ReceiveNotification` 事件,收到到推送的时候会回调 |
| 36 | +``` |
| 37 | +var subscription = NativeAppEventEmitter.addListener( |
| 38 | + 'ReceiveNotification', |
| 39 | + (notification) => console.log(notification) |
| 40 | +); |
| 41 | +``` |
| 42 | + |
| 43 | +监听 `OpenNotificationToLaunchApp` 事件,点击推送**启动 App **的时候会触发这个事件 |
| 44 | + |
| 45 | +``` |
| 46 | +var subscription = NativeAppEventEmitter.addListener( |
| 47 | + 'OpenNotificationToLaunchApp', |
| 48 | + (notification) => console.log(notification) |
| 49 | +); |
| 50 | +``` |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | +监听 `OpenNotification` 事件,点击推送的时候会执行这个回调(注意:iOS10 才开始触发这个事件) |
| 55 | + |
| 56 | +``` |
| 57 | +var subscription = NativeAppEventEmitter.addListener( |
| 58 | + 'OpenNotification', |
| 59 | + (notification) => console.log(notification) |
| 60 | +); |
| 61 | +``` |
| 62 | + |
| 63 | +监听 `networkDidReceiveMessage` 事件,收到 JPush 应用内消息会执行这个回调 |
| 64 | +``` |
| 65 | +var subscription = NativeAppEventEmitter.addListener( |
| 66 | + 'networkDidReceiveMessage', |
| 67 | + (message) => console.log(message) |
| 68 | +); |
| 69 | +``` |
0 commit comments