我指的推送是不运行app情况下收到的通知栏信息
思路:在通知栏点击事件中用SP保存targetId,conversationType,然后在应用启动的Activity获取这信息,进行跳转
首先要确保你已按照融云提供的文档集成第三方vivo推送已经成功
即我们需要自定义VivoPushReceiver
如:
public class VivoPushReceiver extends VivoPushMessageReceiver {
@Override
public void onNotificationMessageClicked(Context context, UPSNotificationMessage message) {
LogUtil.INSTANCE.o("SealNotificationReceiverV",message);
//融云推送
/**
* rongVivoPush的message:
* {"mCompatibleType":0,"mContent":"雨天:看看","mCoverUrl":"","mIconUrl":"","mIsMacroReplace":0,"mMsgId":745945563061671936,"mNotifyType":4,"mParams":{"rc":"{\"conversationType\":\"3\",\"targetId\":\"newUserGroup\",\"sourceType\":\"0\",\"fromUserId\":\"1575_70efba66d3d8d53194fb1a8446ae07fa\",\"objectName\":\"RC:TxtMsg\",\"id\":\"BK16-CM4C-V4EC-U2TK\",\"tId\":\"18082_ad5db5924e3e97ed8a387a499efa9fa0\"}"},"mPurePicUrl":"","mShowTime":true,"mSkipContent":"","mSkipType":1,"mTargetType":0,"mTitle":"创骐云课堂新人指导群","mTragetContent":""}
*/
try {
MParams rVivoPushBean = new Gson().fromJson(message.getParams().toString(),MParams.class);
if (rVivoPushBean != null && rVivoPushBean.getRc() != null && rVivoPushBean.getRc().getTargetId() != null && rVivoPushBean.getRc().getConversationType() != null){
SPUtils.INSTANCE.put(SPKey.INSTANCE.getRONG_VIVO_PUSH_TARGETID(),rVivoPushBean.getRc().getTargetId());
SPUtils.INSTANCE.put(SPKey.INSTANCE.getRONG_VIVO_PUSH_CONVERSATION_TYPE(),Integer.valueOf(rVivoPushBean.getRc().getConversationType()));
//这里写跳转也是没用的
//ImUtils.INSTANCE.startConversationActivity(context, Conversation.ConversationType.setValue(Integer.valueOf(rVivoPushBean.getRc().getConversationType())),rVivoPushBean.getRc().getTargetId(),"群聊");
}
super.onNotificationMessageClicked(context, message);
} catch (Exception e1){
super.onNotificationMessageClicked(context, message);
}
}
@Override
public void onReceiveRegId(Context context, String token) {
super.onReceiveRegId(context, token);
}
}
记得注册清单
<receiver android:name=".im.push.VivoPushReceiver">
<intent-filter>
<!-- 接收 vivo push 消息 -->
<action android:name="com.vivo.pushclient.action.RECEIVE" />
</intent-filter>
</receiver>
启动的Activity
if (!(SPUtils.get(SPKey.RONG_VIVO_PUSH_TARGETID, "") as String).isNullOrBlank() && (SPUtils.get(SPKey.RONG_VIVO_PUSH_CONVERSATION_TYPE, 0) as Int) > 0) {
SPUtils.put(SPKey.RONG_VIVO_PUSH_TARGETID, "")
ImUtils.startConversationActivity(mActivity, Conversation.ConversationType.setValue(SPUtils.get(SPKey.RONG_VIVO_PUSH_CONVERSATION_TYPE, 0) as Int),
(SPUtils.get(SPKey.RONG_VIVO_PUSH_TARGETID, "") as String), "聊天")
return
}
暂时想到这样的方法,有更好的方法可联系我QQ:893151960