Skip to content

Commit

Permalink
bugfix: custom message has no content_type
Browse files Browse the repository at this point in the history
transfer content_type from native to js
  • Loading branch information
lsk-boy-f committed Dec 29, 2019
1 parent 773f1dc commit dd41973
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
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 {Fucntion} callback = (result) => {"messageID":String,"content":String,"extras":{String:String}}}
* @param {Fucntion} 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 @@ -533,10 +534,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

0 comments on commit dd41973

Please sign in to comment.