Skip to content

Commit f700b79

Browse files
Merge pull request #519 from jpush/dev
Dev
2 parents 35d0b9d + 6b464eb commit f700b79

File tree

3 files changed

+31
-22
lines changed

3 files changed

+31
-22
lines changed

android/src/main/java/cn/jpush/reactnativejpush/JPushModule.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@ private static void sendEvent() {
163163
WritableMap map = Arguments.createMap();
164164
map.putInt("id", mCachedBundle.getInt(JPushInterface.EXTRA_NOTIFICATION_ID));
165165
map.putString("message", mCachedBundle.getString(JPushInterface.EXTRA_MESSAGE));
166+
map.putString("content", mCachedBundle.getString(JPushInterface.EXTRA_MESSAGE));
167+
map.putString("content_type", mCachedBundle.getString(JPushInterface.EXTRA_CONTENT_TYPE));
168+
map.putString("title", mCachedBundle.getString(JPushInterface.EXTRA_TITLE));
166169
map.putString("extras", mCachedBundle.getString(JPushInterface.EXTRA_EXTRA));
167170
mRAC.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
168171
.emit(mEvent, map);
@@ -177,7 +180,7 @@ private static void sendEvent() {
177180
.emit(mEvent, map);
178181
break;
179182
}
180-
183+
181184
mEvent = null;
182185
mCachedBundle = null;
183186
}

documents/api.md

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[English document](api_en.md)
22

33
* [Common API](#common-api)
4+
* [initPush](#initpush)
45
* [getRegistrationID](#getregistrationid)
56
* [stopPush](#stoppush)
67
* [resumePush](#resumepush)
@@ -24,7 +25,6 @@
2425
* [点击推送启动应用事件](#open-notification-launch-app-event)
2526
* [网络成功登陆事件](#network-did-login-event)
2627
* [Android Only API](#android-only-api)
27-
* [initPush](#initpush)
2828
* [crashLogOFF](#crashlogoff)
2929
* [crashLogON](#crashlogno)
3030
* [notifyJSDidLoad](#notifyjsdidload)
@@ -37,12 +37,26 @@
3737
* [addGetRegistrationIdListener](#addgetregistrationIdlistener)
3838
* [removeGetRegistrationIdListener](#removegetregistrationidlistener)
3939

40-
注意: 在 Android 需要先调用 `initPush` 方法, iOS 端不需要
40+
注意: 需要调用先调用 `initPush` 方法才能正常使用
4141

4242
### Common API
4343

4444
Android 和 iOS 通用 API。
4545

46+
#### initPush
47+
48+
初始化 JPush,这个方法初始化推送功能 iOS 会弹出获取推送权限的提示框(注意这个系统提示框只会触发一次,如果用户首次不同意,之后需要用户到设置中修改推送权限)。
49+
50+
```
51+
JPushModule.initPush()
52+
```
53+
54+
Android 建议在原生 `MainActivity``onCreate` 中调用:
55+
56+
```
57+
// java 原生代码
58+
JPushInterface.init(this);
59+
```
4660
#### getRegistrationID
4761

4862
* getRegistrationID(function)
@@ -61,20 +75,19 @@ Android 和 iOS 通用 API。
6175
JPushModule.stopPush();
6276
```
6377

64-
* #### resumePush
78+
#### resumePush
6579

66-
恢复推送。建议在 `MainActivity``onResume` 中调用:
80+
恢复推送。建议在 `MainActivity``onResume` 中调用:
6781

68-
```
69-
// android native java
70-
JPushInterface.onResume(this);
71-
```
72-
73-
```
74-
// iOS - javascirpt
75-
JPushModule.resumePush();
76-
```
82+
```
83+
// android native java
84+
JPushInterface.onResume(this);
85+
```
7786

87+
```
88+
// iOS - javascirpt
89+
JPushModule.resumePush();
90+
```
7891
#### setAlias
7992

8093
* setAlias(alias, successCallback)
@@ -365,13 +378,6 @@ JPushModule.getLaunchAppNotification( notification => {
365378

366379
### Android Only API
367380

368-
* #### initPush
369-
370-
初始化 JPush。建议在 `MainActivity``onCreate` 中调用:
371-
372-
```
373-
JPushInterface.init(this);
374-
```
375381

376382
* #### crashLogOFF
377383

example/App.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ export default class App extends Component {
228228

229229
JPushModule.addReceiveCustomMsgListener(map => {
230230
this.setState({
231-
pushMsg: map.message
231+
pushMsg: map.content
232232
})
233233
console.log('extras: ' + map.extras)
234234
})

0 commit comments

Comments
 (0)