小米
当收到推送通知并点击时会回调
io.rong.push.platform.mi.MiMessageReceiver#onNotificationMessageClicked 方法
在以上方法中会发送广播并触发继承 PushMessageReceiver 类的 onNotificationMessageClicked 方法。
在此方法中的参数 PushNotificationMessage 中可以获得以下信息String pushId; //对应推送消息的唯一Id,如果是消息转push,则为消息的uid
RongPushClient.ConversationType conversationType; //会话类型
String objectName; // 消息类型:RC:Txt RC:Img ...
String senderId; // 发送者ID
String senderName; // 发送者名称
Uri senderPortrait; //发送者头像地址
String targetId; // 目标Id。ex: 群里的某人发了一条消息,则targetId为群Id,senderId为群里的这个用户的Id。
String targetUserName; //目标名字。
String toId; //该推送的目标用户。
String pushTitle; //推送消息的标题
String pushContent; //推送消息内容
String pushData; // 客户端发送push消息时的附加字段
String isFromPush; //是push消息时为true, 后台消息时为false
PushSourceType sourceType; //推送来源。
当重写 onNotificationMessageClicked 返回 false 时, SDk 会以以下 action 进行跳转 Activityrong://【你的 ApllicationId】/conversation/private?targetId=【目标 targetId】&title=【推送标题】&isFromPush=true
当在 AndroidManifest.xml 中,您的会话界面 Activity 中加入 Intent-filter 进行拦截即可跳转android:name="您的会话界面 Activity"
>
android:host="你的 ApllicationId"
android:path="/conversation/"
android:scheme="rong" />
华为
当收到推送通知并点击时默认是会以以下 uri 的打开 Activity
rong://【你的 ApllicationId】/conversationlist?isFromPush=true
您需要当在 AndroidManifest.xml 中,您的会话列表界面 Activity 中加入 Intent-filter 进行拦截即可跳转android:name="您的会话界面 Activity"
>
android:host="你的 ApllicationId"
android:path="/conversationlist"
android:scheme="rong" />
在 Intent 中 携带 extrasoptions:{"rc":"{"conversationType":"1","sourceType":"0","fromUserId":"NyKWhpEUl","objectName":"RC:TxtMsg","id":"BF4A-V7G3-85S5-0LG6","tId":"vu0JWCcQY","targetId":"NyKWhpEUl"}"}
可以通过以下方式获取推送相关信息:JSONObject jsonObject = new JSONObject(options);
JSONObject rc = new JSONObject(jsonObject.getString("rc"));
Conversation.ConversationType conversationType =
Conversation.ConversationType.setValue(rc.getInt ("conversationType")); // 会话类型
String targetId = rc.getString("NyKWhpEUl"); // 目标 targetId
然后可以通过以下代码跳转到对应的会话界面中RongIM.getInstance().startConversation(context, conversationType, targetId, "");
魅族
目前魅族点击通知栏时推回调
io.rong.push.platform.meizu.MeiZuReceiver#onNotificationClicked 方法
在以上方法中会发送广播并触发继承 PushMessageReceiver 类的 onNotificationMessageClicked 方法。
在此方法中的参数 PushNotificationMessage 中可以获得以下信息String pushId; //对应推送消息的唯一Id,如果是消息转push,则为消息的uid
RongPushClient.ConversationType conversationType; //会话类型
String objectName; // 消息类型:RC:Txt RC:Img ...
String senderId; // 发送者ID
String senderName; // 发送者名称
Uri senderPortrait; //发送者头像地址
String targetId; // 目标Id。ex: 群里的某人发了一条消息,则targetId为群Id,senderId为群里的这个用户的Id。
String targetUserName; //目标名字。
String toId; //该推送的目标用户。
String pushTitle; //推送消息的标题
String pushContent; //推送消息内容
String pushData; // 客户端发送push消息时的附加字段
String isFromPush; //是push消息时为true, 后台消息时为false
PushSourceType sourceType; //推送来源。
当重写 onNotificationMessageClicked 返回 false 时, SDk 会以以下 action 进行跳转 Activityrong://【你的 ApllicationId】/conversation/private?targetId=【目标 targetId】&title=【推送标题】&isFromPush=true
当在 AndroidManifest.xml 中,您的会话界面 Activity 中加入 Intent-filter 进行拦截即可跳转android:name="您的会话界面 Activity"
>
android:host="你的 ApllicationId"
android:path="/conversation/"
android:scheme="rong" />
同时点击通知栏时还会跳转到您应用桌面入口所对应的 Activity,并在 Intent 通过 getIntent().getExtras() 方式获取的 Bundle 中附带以下内容。sdkVersion: SDK 版本(如:2.10.2)
isShowPushContent:是否显示推送内容(如:1)
rc:推送内容(如:{"conversationType":"1","fromUserId":"发送者用户id","id":"XXXX-XXXX-XXXX-XXXX","objectName":"RC:TxtMsg","sourceType":"0","tId":"接受者用户id"})
timestamp:时间戳
appId:AppKey
channelType:会话类型整形类型(如:1)
receiverUserId:接收消息用户 id
clientOs:操作系统
packageName:包名
content:消息内容
objectName:消息类型名(如:RC:TxtMsg)
fromUserName:用户名称
注意:所以当您在 onNotificationMessageClicked 方法中返回 false,会先跳转到桌面入口对应的 Activity ,然后跳转到注册接受 rong://【你的 ApllicationId】/conversation/ 所对应 Activity。
oppo
点击通知栏时会跳转到您应用桌面入口所对应的 Activity,并在 Intent 通过 getIntent().getExtras() 方式获取的 Bundle 中附带以下内容。sdkVersion: SDK 版本(如:2.10.2)
isShowPushContent:是否显示推送内容(如:1)
rc:推送内容(如:{"conversationType":"1","fromUserId":"发送者用户id","id":"XXXX-XXXX-XXXX-XXXX","objectName":"RC:TxtMsg","sourceType":"0","tId":"接受者用户id"})
timestamp:时间戳
appId:AppKey
channelType:会话类型整形类型(如:1)
receiverUserId:接收消息用户 id
clientOs:操作系统
packageName:包名
content:消息内容
objectName:消息类型名(如:RC:TxtMsg)
fromUserName:用户名称
然后可以通过以下代码跳转到对应的会话界面中Bundle extras = getIntent().getExtras();
JSONObject rc = new JSONObject(extras.getString("rc"));
Conversation.ConversationType conversationType =
Conversation.ConversationType.setValue(rc.getInt("conversationType"));
String targetId = rc.getString("fromUserId");
RongIM.getInstance().startConversation(context, conversationType, targetId, "");
vivo
点击通知栏时会跳转到您应用桌面入口所对应的 Activity,目前 vivo 没有将其他参数传入 Intent 中,即没法跳转到对应用户的会话界面中,我们将在以后的版本中加入会话相关信息。
FCM
当收到推送时会回调
io.rong.push.platform.google.RongFirebaseMessagingService#onMessageReceived 方法
在以上方法中会发送广播并触发继承 PushMessageReceiver 类的 onNotificationMessageArrived 方法。
当 onNotificationMessageArrived 回调返回 false 时,会产一条融云生成的通知栏消息。
当点击该通知时会触发 发继承 PushMessageReceiver 类的 onNotificationMessageClicked 方法。
在此方法中的参数 PushNotificationMessage 中可以获得以下信息String pushId; //对应推送消息的唯一Id,如果是消息转push,则为消息的uid
RongPushClient.ConversationType conversationType; //会话类型
String objectName; // 消息类型:RC:Txt RC:Img ...
String senderId; // 发送者ID
String senderName; // 发送者名称
Uri senderPortrait; //发送者头像地址
String targetId; // 目标Id。ex: 群里的某人发了一条消息,则targetId为群Id,senderId为群里的这个用户的Id。
String targetUserName; //目标名字。
String toId; //该推送的目标用户。
String pushTitle; //推送消息的标题
String pushContent; //推送消息内容
String pushData; // 客户端发送push消息时的附加字段
String isFromPush; //是push消息时为true, 后台消息时为false
PushSourceType sourceType; //推送来源。
当重写 onNotificationMessageClicked 返回 false 时, SDk 会以以下 action 进行跳转 Activityrong://【你的 ApllicationId】/conversation/private?targetId=【目标 targetId】&title=【推送标题】&isFromPush=true
当在 AndroidManifest.xml 中,您的会话界面 Activity 中加入 Intent-filter 进行拦截即可跳转android:name="您的会话界面 Activity"
>
android:host="你的 ApllicationId"
android:path="/conversation/"
android:scheme="rong" />