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

唠一唠融云 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 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 中进行注册即可 。

你可能感兴趣的:(唠一唠融云 VIVO push 无法跳转的解决方案)