
基础产品
适用各种通信场景,接入灵活

融合场景
专为场景打造,接入成本低

扩展能力
核心能力延展,功能全面

更多服务
一站式服务,满足各种需求
回答:
当收到推送通知并点击时会回调
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 进行跳转 Activity
rong://【你的 ApllicationId】/conversation/private?targetId=【目标 targetId】&title=【推送标题】&isFromPush=true
当在 AndroidManifest.xml 中,您的会话界面 Activity 中加入 Intent-filter 进行拦截即可跳转
<activity android:name="您的会话界面 Activity" > <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <data android:host="你的 ApllicationId" android:path="/conversation/" android:scheme="rong" /> </intent-filter> </activity>
当收到推送通知并点击时默认是会以以下 uri 的打开 Activity
rong://【你的 ApllicationId】/conversationlist?isFromPush=true
您需要当在 AndroidManifest.xml 中,您的会话列表界面 Activity 中加入 Intent-filter 进行拦截即可跳转
<activity android:name="您的会话界面 Activity" > <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <data android:host="你的 ApllicationId" android:path="/conversationlist" android:scheme="rong" /> </intent-filter> </activity>
在 Intent 中 携带 extras
options:{"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 进行跳转 Activity
rong://【你的 ApllicationId】/conversation/private?targetId=【目标 targetId】&title=【推送标题】&isFromPush=true
当在 AndroidManifest.xml 中,您的会话界面 Activity 中加入 Intent-filter 进行拦截即可跳转
<activity android:name="您的会话界面 Activity" > <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <data android:host="你的 ApllicationId" android:path="/conversation/" android:scheme="rong" /> </intent-filter> </activity>
同时点击通知栏时还会跳转到您应用桌面入口所对应的 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。
点击通知栏时会跳转到您应用桌面入口所对应的 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 处理方式与小米一致。
透传方式:
当收到推送时会回调
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 进行跳转 Activity
rong://【你的 ApllicationId】/conversation/private?targetId=【目标 targetId】&title=【推送标题】&isFromPush=true
当在 AndroidManifest.xml 中,您的会话界面 Activity 中加入 Intent-filter 进行拦截即可跳转
<activity android:name="您的会话界面 Activity" > <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <data android:host="你的 ApllicationId" android:path="/conversation/" android:scheme="rong" /> </intent-filter> </activity>