xinge-api-java icon indicating copy to clipboard operation
xinge-api-java copied to clipboard

消息自定义附加字段?

Open gguan opened this issue 6 years ago • 4 comments

没法发自定义消息啊

custom 类型是string? 不应该是json吗

gguan avatar Sep 04 '18 07:09 gguan

@gguan 你说的是如下定义吗 代码地址

    @JsonProperty(value = "custom")
    @ApiModelProperty(notes = "自定义下发的参数")
    private String custom;

这里是JSON String 类型的,这里需要传人的是String而不是JSONObject,是为了防止toString的时候多加上引号的问题

caofangkun avatar Sep 05 '18 08:09 caofangkun

可是生成的request custom字段不是json结构啊,直接用api是可以给custom传json的

gguan avatar Sep 06 '18 02:09 gguan

messageIOS.setAps(aps); JSONObject json = new JSONObject(); json.put("redirect","www.baidu.com"); messageIOS.setCustom(json.toString());

现在到了客户端 { aps = { content-available = 0, alert = { title = "", body = "test", }, mutable-content = 0, badge = 1, }, custom = "{"redirect":"www.baidu.com"}", xg = { bid = 0, msgid = 3510883568, ts = 1564717302, }, } @caofangkun 不跟原先一样是个对象... 这个该怎么写入

qbmiller avatar Aug 02 '19 04:08 qbmiller

messageIOS.setAps(aps); JSONObject json = new JSONObject(); json.put("redirect","www.baidu.com"); messageIOS.setCustom(json.toString());

现在到了客户端 { aps = { content-available = 0, alert = { title = "", body = "test", }, mutable-content = 0, badge = 1, }, custom = "{"redirect":"www.baidu.com"}", xg = { bid = 0, msgid = 3510883568, ts = 1564717302, }, } @caofangkun 不跟原先一样是个对象... 这个该怎么写入 改了, 一个String字段改成Object 就可以了, 打包源码,发布到自己私服

qbmiller avatar Aug 11 '19 01:08 qbmiller