关于音视频:唠一唠融云-VIVO-push-无法跳转的解决方案

38次阅读

共计 2231 个字符,预计需要花费 6 分钟才能阅读完成。

在集成融云 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 中进行注册即可。

正文完
 0