Skip to content

Commit dcd6302

Browse files
committed
bugfix: 保持iOS和Android平台下收到同样的自定义消息
参考[Push API v3 - 极光文档](https://docs.jiguang.cn/jpush/server/push/rest_api_v3_push/#message)修改Android下接收到的自定义消息的内容
1 parent c81c883 commit dcd6302

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,9 @@ private static void sendEvent() {
162162
case RECEIVE_CUSTOM_MESSAGE:
163163
WritableMap map = Arguments.createMap();
164164
map.putInt("id", mCachedBundle.getInt(JPushInterface.EXTRA_NOTIFICATION_ID));
165-
map.putString("message", mCachedBundle.getString(JPushInterface.EXTRA_MESSAGE));
165+
map.putString("content", mCachedBundle.getString(JPushInterface.EXTRA_MESSAGE));
166+
map.putString("content_type", mCachedBundle.getString(JPushInterface.EXTRA_CONTENT_TYPE));
167+
map.putString("title", mCachedBundle.getString(JPushInterface.EXTRA_TITLE));
166168
map.putString("extras", mCachedBundle.getString(JPushInterface.EXTRA_EXTRA));
167169
mRAC.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
168170
.emit(mEvent, map);
@@ -177,7 +179,7 @@ private static void sendEvent() {
177179
.emit(mEvent, map);
178180
break;
179181
}
180-
182+
181183
mEvent = null;
182184
mCachedBundle = null;
183185
}

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)