Let's talk about the solution that Rongyun VIVO push cannot jump

Let's talk about the solution that Rongyun VIVO push cannot jump

In the process of integrating Rongyun SDK, it is inevitable to receive pushes. In order to ensure the arrival rate, the manufacturer pushes of Rongyun are integrated. After the integration, a problem is found. After VIVO push receives the notification bar, click Yes For those unable to jump, the problem was solved by consulting Rongyun's technical students.

The following is a solution to this problem, which is recorded here for your reference;

  1. First, you need to copy VivoPushMessageReceiver, and then capture in the onNotificationMessageClicked method;

       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. The transformVivoToPushMessage method can completely copy my method.

     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. Finally, register the duplicated VivoPushMessageReceiver in AndroidMainfest.

Guess you like

Origin blog.51cto.com/15024061/2562499