Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: custom message has no content_type #745

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class JConstants {
public static final String MESSAGE_ID = "messageID";
public static final String TITLE = "title";
public static final String CONTENT = "content";
public static final String CONTENT_TYPE = "content_type";
public static final String EXTRAS = "extras";
//消息事件
public static final String NOTIFICATION_ARRIVED = "notificationArrived";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public static WritableMap convertCustomMessage(CustomMessage customMessage) {
writableMap.putString(JConstants.MESSAGE_ID, customMessage.messageId);
writableMap.putString(JConstants.TITLE, customMessage.title);
writableMap.putString(JConstants.CONTENT, customMessage.message);
writableMap.putString(JConstants.CONTENT_TYPE, customMessage.contentType);
convertExtras(customMessage.extra, writableMap);
return writableMap;
}
Expand Down
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export default class JPush {
JPushModule.getAllTags(params)
}
}

/*
* 设置别名
* 需要理解的是,这个接口是覆盖逻辑,而不是增量逻辑。即新的调用会覆盖之前的设置
Expand Down Expand Up @@ -396,12 +396,14 @@ export default class JPush {
/*
* 自定义消息事件
*
* @param {Function} callback = (result) => {"messageID":String,"content":String,"extras":{String:String}}}
* @param {Function} callback = (result) => {"messageID":String,"content":String, "content_type":String, "extras":{String:String}}}
*
* messageID:唯一标识自定义消息的 ID
*
* content:对应 Portal 推送消息界面上的“自定义消息内容”字段
*
* content_type:对应 Portal 推送消息界面上的“自定义消息内容类型”字段
*
* extras:对应 Portal 推送消息界面上的“可选设置”里的附加字段
*
* */
Expand Down
6 changes: 4 additions & 2 deletions ios/RCTJPushModule/RCTJPushModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#define MESSAGE_ID @"messageID"
#define TITLE @"title"
#define CONTENT @"content"
#define CONTENT_TYPE @"content_type"
#define EXTRAS @"extras"
#define BADGE @"badge"
#define RING @"ring"
Expand Down Expand Up @@ -537,10 +538,11 @@ -(NSDictionary *)convertCustomMessage:(NSNotification *)data
NSString *messageID = objectData[@"_j_msgid"]?objectData[@"_j_msgid"]:@"";
NSString *title = objectData[@"title"]?objectData[@"title"]:@"";
NSString *content = objectData[@"content"]?objectData[@"content"]:@"";
NSString *content_type = objectData[@"content_type"]?objectData[@"content_type"]:@"";
if(objectData[@"extras"]){
responseData = @{MESSAGE_ID:messageID,TITLE:title,CONTENT:content,EXTRAS:objectData[@"extras"]};
responseData = @{MESSAGE_ID:messageID,TITLE:title,CONTENT:content,CONTENT_TYPE:content_type,EXTRAS:objectData[@"extras"]};
}else{
responseData = @{MESSAGE_ID:messageID,TITLE:title,CONTENT:content};
responseData = @{MESSAGE_ID:messageID,TITLE:title,CONTENT:content,CONTENT_TYPE:content_type};
}
return responseData;
}
Expand Down