唠一唠融云 VIVO push 无法跳转的解决方案

171 篇文章 0 订阅
120 篇文章 1 订阅

唠一唠融云 VIVO push 无法跳转的解决方案

在集成融云SDK 的过程中,不可避免的是要收到推送,由于为了保证到达率,所以集成了融云的厂商推送,在集成之后,发现个问题,VIVO 推送收到通知栏之后点击是无法进行跳转的,通过咨询融云的技术同学,解决了此问题。

以下是解决此问题的解决方案,记录在此,以供大家参考;

  1. 首先需要复写 VivoPushMessageReceiver ,然后在 onNotificationMessageClicked 方法中进行捕捉;

      public class MY extends VivoPushMessageReceiver {
       @Override
      public void onNotificationMessageClicked(Context context, UPSNotificationMessage message) {
         
       PushNotificationMessage pushNotificationMessage =  transformVivoToPushMessage(message.getTitle(), message.getContent(), message.getParams());
       if (pushNotificationMessage != null) {
       PushManager.getInstance().onNotificationMessageClicked(context, PushType.VIVO, pushNotificationMessage);
    

    }
    }
    2 . 其中 transformVivoToPushMessage 方法可以完全照抄我一下的方法。

    public static PushNotificationMessage transformVivoToPushMessage(String title, String content, Map<String, String> params) {
    

    if (params == null){
    return null;
    }

    PushNotificationMessage pushNotificationMessage = null;
    String rc = params.get(“rc”);
    if (rc != null) {
    try {
    JSONObject rcJson = new JSONObject(rc);
    pushNotificationMessage = new PushNotificationMessage();

           pushNotificationMessage.setPushTitle(title);
           pushNotificationMessage.setPushContent(content);
    
    
           int conversationType = rcJson.optInt("conversationType");
           pushNotificationMessage.setConversationType(RongPushClient.ConversationType.setValue(conversationType));
    
    
           int sourceType = rcJson.optInt("sourceType");
           pushNotificationMessage.setSourceType(getType(sourceType));
    
    
           pushNotificationMessage.setSenderId(rcJson.optString("fromUserId"));
           pushNotificationMessage.setObjectName(rcJson.optString("objectName"));
           pushNotificationMessage.setPushId(rcJson.optString("id"));
           pushNotificationMessage.setToId(rcJson.optString("tId"));
           pushNotificationMessage.setTargetId(rcJson.optString("targetId"));
    
    
           String appData = params.get("appData");
           if (appData != null) {
               pushNotificationMessage.setPushData(appData);
           }
       } catch (JSONException e) {
           RLog.e("PushUtils", "transformToPushMessage:" + e.getMessage());
           pushNotificationMessage = null;
       }
    

    }
    return pushNotificationMessage;
    }

    public static PushNotificationMessage.PushSourceType getType(int type) {
    for (PushNotificationMessage.PushSourceType sourceType : PushNotificationMessage.PushSourceType.values()) {
    if (sourceType.ordinal() == type) {
    return sourceType;
    }
    }

    return PushNotificationMessage.PushSourceType.LOCAL_MESSAGE;
    }

3 . 最后,将复写的 VivoPushMessageReceiver 在AndroidMainfest 中进行注册即可 。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值