接入华为推送点击
This commit is contained in:
@@ -385,6 +385,18 @@
|
||||
android:screenOrientation="behind"
|
||||
android:windowSoftInputMode="adjustResize|stateHidden" />
|
||||
|
||||
<activity android:name=".push.HWPushMiddleActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<data
|
||||
android:host="com.huawei.codelabpush"
|
||||
android:path="/deeplink"
|
||||
android:scheme="pushscheme" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="com.tencent.bugly.beta.ui.BetaActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize|locale"
|
||||
|
@@ -115,6 +115,7 @@ import com.yizhuan.erban.ui.widget.MainTabLayout;
|
||||
import com.yizhuan.erban.ui.widget.RecallDialog;
|
||||
import com.yizhuan.erban.ui.widget.RedPacketDialog;
|
||||
import com.yizhuan.erban.utils.CleanLeakUtils;
|
||||
import com.yizhuan.erban.utils.PushMessageHandler;
|
||||
import com.yizhuan.xchat_android_core.Constants;
|
||||
import com.yizhuan.xchat_android_core.UriProvider;
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel;
|
||||
@@ -1211,22 +1212,20 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
|
||||
if (NimMiddleActivity.delayOpenCommunity) {
|
||||
return;
|
||||
}
|
||||
// if (NimMiddleActivity.openCommunity) {
|
||||
// NimMiddleActivity.openCommunity = false;
|
||||
LogUtils.e("NimMiddleActivity"+NimMiddleActivity.payloadUid);
|
||||
|
||||
if (NimMiddleActivity.openCommunity) {
|
||||
NimMiddleActivity.openCommunity = false;
|
||||
if (NimMiddleActivity.skipType == 0)return;
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (NimMiddleActivity.skipType == 2){
|
||||
if (NimMiddleActivity.skipType == PushMessageHandler.PAYLOAD_SKIPTYPE_INVITE_FANS){
|
||||
AVRoomActivity.start(MainActivity.this,NimMiddleActivity.payloadUid);
|
||||
}else if (NimMiddleActivity.skipType == 4){
|
||||
}else if (NimMiddleActivity.skipType == PushMessageHandler.PAYLOAD_SKIPTYPE_PRIVATE_MSG){
|
||||
NimP2PMessageActivity.start(MainActivity.this, NimMiddleActivity.payloadUid + "");
|
||||
}
|
||||
}
|
||||
}, 2000);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
private Single<ChannelPageInfo> handleChannelPageInfo(boolean isSplashOrLinkedme) {
|
||||
|
@@ -0,0 +1,37 @@
|
||||
package com.yizhuan.erban.push;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
|
||||
import com.yizhuan.erban.MainActivity;
|
||||
import com.yizhuan.erban.avroom.activity.AVRoomActivity;
|
||||
import com.yizhuan.erban.ui.im.avtivity.NimP2PMessageActivity;
|
||||
import com.yizhuan.erban.utils.PushMessageHandler;
|
||||
|
||||
public class HWPushMiddleActivity extends Activity {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
Intent intent = getIntent();
|
||||
if (null != intent) {
|
||||
// 方法2设置的数据通过如下方式获取
|
||||
MainActivity.start(this);
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
int skiptype = intent.getIntExtra("skiptype",0);
|
||||
if (skiptype == PushMessageHandler.PAYLOAD_SKIPTYPE_INVITE_FANS){
|
||||
String roomUid = intent.getStringExtra("roomUid");
|
||||
AVRoomActivity.start(HWPushMiddleActivity.this,Long.parseLong(roomUid));
|
||||
}else if (skiptype == PushMessageHandler.PAYLOAD_SKIPTYPE_PRIVATE_MSG){
|
||||
String uid = intent.getStringExtra("uid");
|
||||
NimP2PMessageActivity.start(HWPushMiddleActivity.this, uid);
|
||||
}
|
||||
}
|
||||
}, 2000);
|
||||
}
|
||||
finish();
|
||||
}
|
||||
}
|
@@ -1,13 +0,0 @@
|
||||
package com.yizhuan.erban.push;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.netease.nimlib.sdk.mixpush.HWPushMessageService;
|
||||
import com.orhanobut.logger.Logger;
|
||||
import com.yizhuan.xchat_android_core.statistic.StatisticManager;
|
||||
|
||||
public class HwPushMessageReceiver extends HWPushMessageService {
|
||||
|
||||
|
||||
}
|
@@ -4,6 +4,7 @@ import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.media.AudioManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
@@ -15,7 +16,7 @@ import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import com.coorchice.library.utils.LogUtils;
|
||||
import com.google.gson.Gson;
|
||||
import com.netease.nim.uikit.api.UIKitOptions;
|
||||
@@ -85,6 +86,8 @@ import com.yizhuan.xchat_android_library.utils.config.BasicConfig;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -476,7 +479,7 @@ public class MessageFragment extends TFragment implements ModuleProxy, MessageLi
|
||||
public void onEvent(CustomNotification messages) {
|
||||
if (messages != null) {
|
||||
try {
|
||||
JSONObject object = JSON.parseObject(messages.getContent());
|
||||
com.alibaba.fastjson.JSONObject object = JSON.parseObject(messages.getContent());
|
||||
ImGameInfo matchInfo = new Gson().fromJson(object.toJSONString(), ImGameInfo.class);
|
||||
if (matchInfo == null || TextUtils.isEmpty(matchInfo.getGameUrl())) return;
|
||||
messageListPanel.receiveCustomNotification(matchInfo);
|
||||
@@ -508,15 +511,16 @@ public class MessageFragment extends TFragment implements ModuleProxy, MessageLi
|
||||
message = changeToRobotMsg(message);
|
||||
Map<String, Object> payload = new HashMap<>();
|
||||
payload.put("skiptype", PushMessageHandler.PAYLOAD_SKIPTYPE_PRIVATE_MSG);
|
||||
try {
|
||||
JSONObject dataObj = new JSONObject();
|
||||
dataObj.put("uid",message.getFromAccount());
|
||||
dataObj.put("content",message.getContent());
|
||||
payload.put("data",dataObj);
|
||||
//vivo开启系统推送
|
||||
int classification = 1;
|
||||
Map<String, Object> vivoField = new HashMap<>();
|
||||
vivoField.put("classification", classification);
|
||||
payload.put("vivoField", vivoField);
|
||||
dataObj.putOpt("uid",message.getFromAccount()).putOpt("content",message.getContent());
|
||||
payload.put("data",dataObj);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
payload.put("vivoField", vivoField());
|
||||
payload.put("hwField", hwField(message));
|
||||
message.setPushPayload(payload);
|
||||
|
||||
final IMMessage msg = message;
|
||||
@@ -547,6 +551,48 @@ public class MessageFragment extends TFragment implements ModuleProxy, MessageLi
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* vivo推送payload
|
||||
* @return
|
||||
*/
|
||||
private Map<String, Object> vivoField(){
|
||||
//vivo开启系统推送
|
||||
int classification = 1;
|
||||
Map<String, Object> vivoField = new HashMap<>();
|
||||
vivoField.put("classification", classification);
|
||||
return vivoField;
|
||||
}
|
||||
|
||||
/**
|
||||
* 华为推送payload
|
||||
* @return
|
||||
*/
|
||||
private JSONObject hwField(IMMessage message){
|
||||
Intent hwIntent = new Intent(Intent.ACTION_VIEW);
|
||||
String intentStr = String.format(
|
||||
"pushscheme://com.huawei.codelabpush/deeplink?sessionID=%s&sessionType=%s",
|
||||
sessionId, sessionType
|
||||
);
|
||||
hwIntent.putExtra("skiptype",PushMessageHandler.PAYLOAD_SKIPTYPE_PRIVATE_MSG);
|
||||
hwIntent.putExtra("uid",message.getFromAccount());
|
||||
hwIntent.setData(Uri.parse(intentStr));
|
||||
hwIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
String intentUri = hwIntent.toUri(Intent.URI_INTENT_SCHEME);
|
||||
//点击事件的内容
|
||||
JSONObject clickAction = new JSONObject();
|
||||
//通知的内容
|
||||
JSONObject notification = new JSONObject();
|
||||
|
||||
try {
|
||||
clickAction.putOpt("type", 1)
|
||||
.putOpt("intent", intentUri);
|
||||
notification.putOpt("click_action", clickAction);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return notification;
|
||||
}
|
||||
|
||||
// 被对方拉入黑名单后,发消息失败的交互处理
|
||||
private void sendFailWithBlackList(int code, IMMessage msg) {
|
||||
if (code == ResponseCode.RES_IN_BLACK_LIST) {
|
||||
|
@@ -21,5 +21,5 @@ with_jenkins=false
|
||||
#\u6253\u652F\u6301x86\u7684\u6A21\u62DF\u5668\u5305\u4F7F\u7528
|
||||
ndk_abi_filters=arm
|
||||
|
||||
version_name=1.2.2
|
||||
version_code=122
|
||||
version_name=1.3.0
|
||||
version_code=130
|
Reference in New Issue
Block a user