通过Tencent TIM SDK发送消息之后,几款主流手机得到的离线推送内容样式

工作回顾 


TIM发送消息

   public static MessageInfo buildCustomJsonMessage(String type, String message) {
        // 发送一条文本消息"nice to meet u",并在消息中 @ 群成员 user1
        TIMMessage msg = new TIMMessage();
            TIMTextElem txtElem = new TIMTextElem();//第一个元素是文本元素
            txtElem.setText(message);
            if (msg.addElement(txtElem) != 0) {
                QLog.e("MessageInfoUtil", "add text elem failed");
                return null;
            }

            // 填充自定义的消息协议
            JSONObject remindProto = new JSONObject();
            remindProto.put("type", type);
            remindProto.put("message", message);
            // 根据自己定义的协议构建自定义消息元素
            TIMCustomElem customElem = new TIMCustomElem();
            //customElem.setDesc("remind msg");
            customElem.setData(remindProto.toString().getBytes("utf-8"));
            //setExt在推送消息中的ext字段添加内容extras=Bundle[{pushMsg=[{"ext":"fghbj"},{"msgid":"15715871"}]}]
            customElem.setExt(message.getBytes());

            //一条组合消息中只能包含一个 TIMCustomElem 自定义消息元素。
            if (msg.addElement(customElem) != 0) {
                QLog.e("MessageInfoUtil", "add custom elem failed");
                return null;
            }

        MessageInfo info = new MessageInfo();

        info.setExtra(message);
        info.setMsgTime(System.currentTimeMillis());
        info.setSelf(true);
        info.setTIMMessage(msg);
        info.setFromUser(TIMManager.getInstance().getLoginUser());
        info.setMsgType(MessageInfo.MSG_TYPE_TEXT);

        return info;
    }

通知栏消息点击后
------------------------------
小米得到离线推送内容
   @Override
    public void onNotificationMessageClicked(Context context, MiPushMessage miPushMessage) {
        Log.d(TAG, "push event onNotificationMessageClicked: "+miPushMessage.toString());
        //默认不会主动打开程序
     }
messageId={scm54095558589703691T9},
passThrough={0},alias={null},topic={null},userAccount={null},content={%E9%A3%8E%E5%AF%92},description={风寒},
title={(001、test)},isNotified={true},notifyId={1},notifyType={-1}, category={null},
extra={{ext=风寒, sound_uri=android.resource://com.sunshine.mhs.pension.physician/2131492864, msgid=15618349}}

2019-05-28  ? D/XiaomiMsgReceiver: push event onNotificationMessageClicked: messageId={scm52316559021115698WF},
passThrough={0},alias={null},topic={null},userAccount={null},content={%E8%A1%8C%E6%AD%A3%E7%89%88%7Bcustom+msg%7D},description={行正版{custom msg}},
title={新消息},isNotified={true},notifyId={1},notifyType={-1}, category={null},
extra={{ext={"type":"2","message":"行正版"}, sound_uri=android.resource://com.sunshine.mhs.pension.physician/2131492864, msgid=3427396861}}
-----
华为得到离线推送内容
   @Override
    public void onEvent(Context context, Event event, Bundle extras) {
        Log.i(TAG, "push event onEvent:"+" "+event.name()+" extras="+extras.toString());
    ...默认打开程序
    }
push event onEvent: NOTIFICATION_OPENED extras=Bundle[{pushMsg=[{"ext":"fghbj"},{"msgid":"15715871"}]}]
通过msg.extra方法获取到封装好的json字符串,这个JSON是和后台商量好的(包含:打开APP,打开链接,跳转到指定页面,统称为:type)
-----

VIVO得到离线推送内容(无法获取内容。只能把消息内容放在customElem.setDesc)
不管是发送text还是custom,vivo接收的东西是一样的。
public class VIVOPushMessageReceiverImpl extends OpenClientPushMessageReceiver {
    onNotificationMessageClicked(Context context, UPSNotificationMessage upsNotificationMessage)
2019-05-29  com.sunshine.mhs.pension.physician I/VIVOPushMessageReceiver: push event onNotificationMessageClicked:UPSNotificationMessage{mTargetType=0, mTragetContent='', mTitle='新消息', mContent='fhjk{custom msg}', mNotifyType=4, mPurePicUrl='', mIconUrl='', mCoverUrl='', mSkipContent='', mSkipType=1, mShowTime=false, mMsgId=583261107864555520, mParams={}}
2019-05-29  com.sunshine.mhs.pension.physician I/vivopush: open vivo push success regId = 15590998731281250806076

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

微澜-

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值