version:3.4.7

fix:
update:更换推送
This commit is contained in:
2025-12-16 17:57:11 +08:00
parent f7ee1df00a
commit cce093aca9
14 changed files with 861 additions and 467 deletions

View File

@@ -78,8 +78,8 @@ android {
official {
flavorDimensions "default"
versionCode 86
versionName "3.4.6"
versionCode 87
versionName "3.4.7"
}
}
@@ -543,6 +543,8 @@ dependencies {
implementation 'com.tencent.bugly:crashreport:4.1.9.2'
//腾讯移动推送 TPNS
implementation 'com.tencent.tpns:tpns:1.4.4.2-release'
//阿里云推送
implementation 'com.aliyun.ams:alicloud-android-push:3.8.0'
//百度地图
implementation 'com.baidu.lbsyun:BaiduMapSDK_Location:9.1.8'
//工具类

View File

@@ -227,7 +227,7 @@
<!-- 【可选】APP实现的Receiver用于接收消息透传和操作结果的回调请根据需要添加 -->
<!-- YOUR_PACKAGE_PATH.CustomPushReceiver需要改为自己的Receiver -->
<receiver android:name=".tpush.MessageReceiver">
<receiver android:name=".push.tpush.MessageReceiver">
<intent-filter>
<!-- 接收消息透传 -->
@@ -238,7 +238,33 @@
</intent-filter>
</receiver>
<receiver
android:name=".push.alipush.AliyunMessageReceiver"
android:exported="false">
<intent-filter>
<action android:name="com.alibaba.push2.action.NOTIFICATION_OPENED" />
</intent-filter>
<intent-filter>
<action android:name="com.alibaba.push2.action.NOTIFICATION_REMOVED" />
</intent-filter>
<intent-filter>
<action android:name="com.alibaba.sdk.android.push.RECEIVE" />
</intent-filter>
</receiver>
<!-- <service -->
<!-- android:name=".push.alipush.AliMessageIntentService" -->
<!-- android:exported="false"> -->
<!-- <intent-filter> -->
<!-- <action android:name="com.alibaba.push2.action.NOTIFICATION_OPENED" /> -->
<!-- </intent-filter> -->
<!-- <intent-filter> -->
<!-- <action android:name="com.alibaba.push2.action.NOTIFICATION_REMOVED" /> -->
<!-- </intent-filter> -->
<!-- <intent-filter> -->
<!-- <action android:name="com.alibaba.sdk.android.push.RECEIVE" /> -->
<!-- </intent-filter> -->
<!-- </service> -->
<!-- 【必须】 请修改为 APP 的 AccessId“15”开头的10位数字中间没空格 -->
<meta-data
@@ -253,5 +279,14 @@
<meta-data
android:name="com.baidu.lbsapi.API_KEY"
android:value="${AK}" />
<!-- 请填写你自己的- appKey -->
<meta-data
android:name="com.alibaba.app.appkey"
android:value="335596359" />
<!-- 请填写你自己的appSecret -->
<meta-data
android:name="com.alibaba.app.appsecret"
android:value="9995cad535ee42e99d299b3f0e18fcc6" />
</application>
</manifest>

View File

@@ -7,20 +7,13 @@ import android.media.AudioManager;
import android.os.Environment;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import android.util.Log;
import com.alibaba.sdk.android.push.CloudPushService;
import com.alibaba.sdk.android.push.CommonCallback;
import com.alibaba.sdk.android.push.noonesdk.PushServiceFactory;
import com.arialyy.aria.core.Aria;
import com.fuying.sn.service.ControlPanelService;
import com.fuying.sn.service.DownloadService;
import com.fuying.sn.service.GuardService;
import com.fuying.sn.service.ManagerService;
import com.fuying.sn.service.StepService;
import com.fuying.sn.service.main.MainService;
import com.tencent.android.tpush.XGIOperateCallback;
import com.tencent.android.tpush.XGPushConfig;
import com.tencent.android.tpush.XGPushManager;
import com.tencent.bugly.crashreport.CrashReport;
import com.tencent.mmkv.MMKV;
import com.fuying.sn.BuildConfig;
import com.fuying.sn.desktop.RunningAppManager;
import com.fuying.sn.desktop.TimeControlManager;
@@ -29,11 +22,23 @@ import com.fuying.sn.manager.ConnectManager;
import com.fuying.sn.manager.ControlManager;
import com.fuying.sn.manager.DeviceManager;
import com.fuying.sn.network.NetInterfaceManager;
import com.fuying.sn.push.PushManager;
import com.fuying.sn.rlog.LogDBManager;
import com.fuying.sn.service.ControlPanelService;
import com.fuying.sn.service.DownloadService;
import com.fuying.sn.service.GuardService;
import com.fuying.sn.service.ManagerService;
import com.fuying.sn.service.StepService;
import com.fuying.sn.service.main.MainService;
import com.fuying.sn.utils.AppUsedTimeUtils;
import com.fuying.sn.utils.JGYUtils;
import com.fuying.sn.utils.SystemUtils;
import com.fuying.sn.utils.Utils;
import com.tencent.android.tpush.XGIOperateCallback;
import com.tencent.android.tpush.XGPushConfig;
import com.tencent.android.tpush.XGPushManager;
import com.tencent.bugly.crashreport.CrashReport;
import com.tencent.mmkv.MMKV;
import java.util.ArrayList;
import java.util.List;
@@ -69,10 +74,13 @@ public class BaseApplication extends Application {
if (!BuildConfig.DEBUG) {
catchException();
}
tPushInit();
String rootDir = MMKV.initialize(this);
Log.i(TAG, "mmkv root: " + rootDir);
PushManager.init(this);
aliyunPushInit();
tPushInit();
JGYUtils.init(this);
CrashReport.initCrashReport(getApplicationContext(), "e5f026c8d5", false);
CrashReport.setDeviceId(this, Utils.getSerial());
@@ -129,6 +137,65 @@ public class BaseApplication extends Application {
});
}
private void aliyunPushInit() {
PushServiceFactory.init(this);
CloudPushService pushService = PushServiceFactory.getCloudPushService();
pushService.setLogLevel(CloudPushService.LOG_DEBUG);
pushService.register(this, new CommonCallback() {
@Override
public void onSuccess(String response) {
Log.e("AliyunPush", "init cloudchannel success");
Log.e("AliyunPush", "init cloudchannel success " + pushService.getDeviceId());
String sn = Utils.getSerial();
Log.e(TAG, "AliyunPush: sn=" + sn);
if (TextUtils.isEmpty(sn)) {
return;
}
pushService.bindAccount(sn, new CommonCallback() {
@Override
public void onSuccess(String s) {
Log.e("AliyunPush", "bind account " + sn + " success\n");
}
@Override
public void onFailed(String errorCode, String errorMsg) {
Log.e("AliyunPush", "bind account " + sn + " failed." +
"errorCode: " + errorCode + ", errorMsg:" + errorMsg);
}
});
pushService.addAlias(sn, new CommonCallback() {
@Override
public void onSuccess(String s) {
Log.e("AliyunPush", "add alias " + sn + " success\n");
}
@Override
public void onFailed(String errorCode, String errorMsg) {
Log.e("AliyunPush", "add alias " + sn + " failed." +
"errorCode: " + errorCode + ", errorMsg:" + errorMsg + "\n");
}
});
pushService.bindTag(CloudPushService.DEVICE_TARGET, new String[]{BuildConfig.platform}, null, new CommonCallback() {
@Override
public void onSuccess(String s) {
Log.e("AliyunPush", "add tag " + sn + " success\n");
}
@Override
public void onFailed(String errorCode, String errorMsg) {
Log.e("AliyunPush", "add tag " + sn + " failed." +
"errorCode: " + errorCode + ", errorMsg:" + errorMsg + "\n");
}
});
}
@Override
public void onFailed(String errorCode, String errorMessage) {
Log.e("AliyunPush", "init cloudchannel failed -- errorcode:" + errorCode + " -- errorMessage:" + errorMessage);
}
});
}
private void tPushInit() {
XGPushConfig.enableDebug(this, true);
XGPushConfig.enablePullUpOtherApp(this, false);

View File

@@ -195,14 +195,17 @@ public class RunningAppManager {
Log.d(TAG, "checkForegroundAppName: appPackageName = " + appPackageName);
if (!JGYUtils.getInstance().isScreenOn()) {
Log.d(TAG, "checkForegroundAppName: isScreenOn = false");
if (!TextUtils.isEmpty(appPackageName)) {
NetInterfaceManager.getInstance().sendCloseApp(appPackageName, new NetInterfaceManager.CompleteCallback() {
@Override
public void onComplete() {
NetInterfaceManager.getInstance().getAppTimeControl();
NetInterfaceManager.getInstance().getSnTimeControl();
}
});
Log.d(TAG, "checkForegroundAppName: isEmpty = false");
// TODO: 2025/11/11 不确定是否因为这里导致网络请求频繁
// NetInterfaceManager.getInstance().sendCloseApp(appPackageName, new NetInterfaceManager.CompleteCallback() {
// @Override
// public void onComplete() {
// NetInterfaceManager.getInstance().getAppTimeControl();
// NetInterfaceManager.getInstance().getSnTimeControl();
// }
// });
}
mMMKV.encode(RUNNING_APP_PACKAGENAME, "");
AppUsedTimeUtils.getInstance().setApp_package("");

View File

@@ -17,6 +17,9 @@ import android.util.Log;
import androidx.core.content.ContextCompat;
import com.alibaba.sdk.android.push.CloudPushService;
import com.alibaba.sdk.android.push.CommonCallback;
import com.alibaba.sdk.android.push.noonesdk.PushServiceFactory;
import com.fuying.sn.BuildConfig;
import com.fuying.sn.bean.AppAndWhiteBean;
import com.fuying.sn.bean.AppInfo;
@@ -115,6 +118,7 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -763,6 +767,22 @@ public class NetInterfaceManager {
Log.e("clearAndAppendTags", "onFail: " + o);
}
});
String[] tagSets = new ArrayList<>(set).toArray(new String[set.size()]);
CloudPushService pushService = PushServiceFactory.getCloudPushService();
pushService.bindTag(CloudPushService.DEVICE_TARGET, tagSets, null, new CommonCallback() {
@Override
public void onSuccess(String s) {
Log.e("AliyunPush", "bind tag " + Arrays.toString(tagSets) + " success\n");
}
@Override
public void onFailed(String errorCode, String errorMsg) {
Log.e("AliyunPush", "bind tag " + Arrays.toString(tagSets) + " failed." +
"errorCode: " + errorCode + ", errorMsg:" + errorMsg + "\n");
}
});
}
private void clearAndAppendTags(Set<String> tagSets) {
@@ -783,6 +803,21 @@ public class NetInterfaceManager {
Log.e("clearAndAppendTags", "onFail: " + o);
}
});
String[] set = new ArrayList<>(tagSets).toArray(new String[tagSets.size()]);
CloudPushService pushService = PushServiceFactory.getCloudPushService();
pushService.bindTag(CloudPushService.DEVICE_TARGET, set, null, new CommonCallback() {
@Override
public void onSuccess(String s) {
Log.e("AliyunPush", "bind tag " + Arrays.toString(set) + " success\n");
}
@Override
public void onFailed(String errorCode, String errorMsg) {
Log.e("AliyunPush", "bind tag " + Arrays.toString(set) + " failed." +
"errorCode: " + errorCode + ", errorMsg:" + errorMsg + "\n");
}
});
}
});
}

View File

@@ -0,0 +1,99 @@
package com.fuying.sn.push.alipush;
import android.content.Context;
import android.util.Log;
import com.alibaba.sdk.android.push.AliyunMessageIntentService;
import com.alibaba.sdk.android.push.notification.CPushMessage;
import java.util.Map;
/**
* Created by liyazhou on 17/8/22.
* 为避免推送广播被系统拦截的小概率事件,我们推荐用户通过IntentService处理消息互调,接入步骤:
* 1. 创建IntentService并继承AliyunMessageIntentService
* 2. 覆写相关方法,并在Manifest的注册该Service
* 3. 调用接口CloudPushService.setPushIntentService
* 详细用户可参考:https://help.aliyun.com/document_detail/30066.html#h2-2-messagereceiver-aliyunmessageintentservice
*/
public class AliMessageIntentService extends AliyunMessageIntentService {
private static final String TAG = "AliyunMessageIntentService";
/**
* 推送通知的回调方法
*
* @param context
* @param title
* @param summary
* @param extraMap
*/
@Override
protected void onNotification(Context context, String title, String summary, Map<String, String> extraMap) {
Log.i(TAG, "收到一条推送通知 " + title + ", summary:" + summary);
}
/**
* 推送消息的回调方法
*
* @param context
* @param cPushMessage
*/
@Override
protected void onMessage(Context context, CPushMessage cPushMessage) {
Log.i(TAG, "收到一条推送消息 " + cPushMessage.getTitle() + ", content:" + cPushMessage.getContent());
}
/**
* 从通知栏打开通知的扩展处理
*
* @param context
* @param title
* @param summary
* @param extraMap
*/
@Override
protected void onNotificationOpened(Context context, String title, String summary, String extraMap) {
Log.i(TAG, "onNotificationOpened " + " : " + title + " : " + summary + " : " + extraMap);
}
/**
* 无动作通知点击回调。当在后台或阿里云控制台指定的通知动作为无逻辑跳转时,通知点击回调为onNotificationClickedWithNoAction而不是onNotificationOpened
*
* @param context
* @param title
* @param summary
* @param extraMap
*/
@Override
protected void onNotificationClickedWithNoAction(Context context, String title, String summary, String extraMap) {
Log.i(TAG, "onNotificationClickedWithNoAction " + " : " + title + " : " + summary + " : " + extraMap);
}
/**
* 通知删除回调
*
* @param context
* @param messageId
*/
@Override
protected void onNotificationRemoved(Context context, String messageId) {
Log.i(TAG, "onNotificationRemoved " + messageId);
}
/**
* 应用处于前台时通知到达回调。注意:该方法仅对自定义样式通知有效,相关详情请参考https://help.aliyun.com/document_detail/30066.html#h3-3-4-basiccustompushnotification-api
*
* @param context
* @param title
* @param summary
* @param extraMap
* @param openType
* @param openActivity
* @param openUrl
*/
@Override
protected void onNotificationReceivedInApp(Context context, String title, String summary, Map<String, String> extraMap, int openType, String openActivity, String openUrl) {
Log.i(TAG, "onNotificationReceivedInApp " + " : " + title + " : " + summary + " " + extraMap + " : " + openType + " : " + openActivity + " : " + openUrl);
}
}

View File

@@ -0,0 +1,116 @@
package com.fuying.sn.push.alipush;
import android.content.Context;
import android.util.Log;
import com.alibaba.sdk.android.push.MessageReceiver;
import com.alibaba.sdk.android.push.notification.CPushMessage;
import com.fuying.sn.push.PushManager;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import java.util.Map;
/**
* @author: 正纬
* @since: 15/4/9
* @version: 1.1
* @feature: 用于接收推送的通知和消息
*/
public class AliyunMessageReceiver extends MessageReceiver {
// 消息接收部分的LOG_TAG
public static final String TAG = "AliyunMessageReceiver";
/**
* 推送通知的回调方法
*
* @param context
* @param title
* @param summary
* @param extraMap
*/
@Override
public void onNotification(Context context, String title, String summary, Map<String, String> extraMap) {
// TODO 处理推送通知
if (null != extraMap) {
for (Map.Entry<String, String> entry : extraMap.entrySet()) {
Log.i(TAG, "@Get diy param : Key=" + entry.getKey() + " , Value=" + entry.getValue());
}
} else {
Log.i(TAG, "@收到通知 && 自定义消息为空");
}
Log.i(TAG, "收到一条推送通知 " + title + ", summary:" + summary);
}
/**
* 应用处于前台时通知到达回调。注意:该方法仅对自定义样式通知有效,相关详情请参考https://help.aliyun.com/document_detail/30066.html?spm=5176.product30047.6.620.wjcC87#h3-3-4-basiccustompushnotification-api
*
* @param context
* @param title
* @param summary
* @param extraMap
* @param openType
* @param openActivity
* @param openUrl
*/
@Override
protected void onNotificationReceivedInApp(Context context, String title, String summary, Map<String, String> extraMap, int openType, String openActivity, String openUrl) {
Log.i(TAG, "onNotificationReceivedInApp " + " : " + title + " : " + summary + " " + extraMap + " : " + openType + " : " + openActivity + " : " + openUrl);
}
/**
* 推送消息的回调方法
*
* @param context
* @param cPushMessage
*/
@Override
public void onMessage(Context context, CPushMessage cPushMessage) {
Log.e(TAG, "收到一条推送消息 " + cPushMessage.getTitle() + ", content:" + cPushMessage.getContent());
String title = cPushMessage.getTitle();
String content = cPushMessage.getContent();
JsonObject extrasJson = JsonParser.parseString(content).getAsJsonObject();
String extras = "";
if (extrasJson.get("extras") != null) {
extras = extrasJson.get("extras").toString();
}
PushManager.getInstance().setPushContent(title, extras);
}
/**
* 从通知栏打开通知的扩展处理
*
* @param context
* @param title
* @param summary
* @param extraMap
*/
@Override
public void onNotificationOpened(Context context, String title, String summary, String extraMap) {
Log.i(TAG, "onNotificationOpened " + " : " + title + " : " + summary + " : " + extraMap);
}
/**
* 通知删除回调
*
* @param context
* @param messageId
*/
@Override
public void onNotificationRemoved(Context context, String messageId) {
Log.i(TAG, "onNotificationRemoved " + messageId);
}
/**
* 无动作通知点击回调。当在后台或阿里云控制台指定的通知动作为无逻辑跳转时,通知点击回调为onNotificationClickedWithNoAction而不是onNotificationOpened
*
* @param context
* @param title
* @param summary
* @param extraMap
*/
@Override
protected void onNotificationClickedWithNoAction(Context context, String title, String summary, String extraMap) {
Log.i(TAG, "onNotificationClickedWithNoAction " + " : " + title + " : " + summary + " : " + extraMap);
}
}

View File

@@ -1,4 +1,4 @@
package com.fuying.sn.tpush;
package com.fuying.sn.push.tpush;
/**
* Created by chacewang on 2019/7/5.

View File

@@ -0,0 +1,297 @@
package com.fuying.sn.push.tpush;
import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;
import com.fuying.sn.push.tpush.common.NotificationService;
import com.fuying.sn.push.tpush.po.XGNotification;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.tencent.android.tpush.NotificationAction;
import com.tencent.android.tpush.XGPushBaseReceiver;
import com.tencent.android.tpush.XGPushClickedResult;
import com.tencent.android.tpush.XGPushRegisterResult;
import com.tencent.android.tpush.XGPushShowedResult;
import com.tencent.android.tpush.XGPushTextMessage;
import java.text.SimpleDateFormat;
import java.util.Calendar;
public class MessageReceiver extends XGPushBaseReceiver {
public static final String UPDATE_LISTVIEW_ACTION = "com.qq.xgdemo.activity.UPDATE_LISTVIEW";
public static final String TEST_ACTION = "com.qq.xgdemo.activity.TEST_ACTION";
public static final String LogTag = "xg.test";
private static final String TAG = "MessageReceiver";
/**
* 消息透传处理
*
* @param context
* @param message 解析自定义的 JSON
*/
@Override
public void onTextMessage(Context context, XGPushTextMessage message) {
String text = "收到消息:" + message.toString();
// 获取自定义key-value
String customContent = message.getCustomContent();
if (customContent != null && customContent.length() != 0) {
JsonObject obj = JsonParser.parseString(customContent).getAsJsonObject();
// key1为前台配置的key
if (!TextUtils.isEmpty(obj.get("key").getAsString())) {
String value = obj.get("key").getAsString();
Log.d(LogTag, "get custom value:" + value);
}
// ...
}
// APP自主处理消息的过程...
Log.e(LogTag, text);
show(context, text);
processCustomMessage(context, message);
}
/**
* 通知展示
*
* @param context
* @param notifiShowedRlt 包含通知的内容
*/
@Override
public void onNotificationShowedResult(Context context, XGPushShowedResult notifiShowedRlt) {
if (context == null || notifiShowedRlt == null) {
return;
}
XGNotification notific = new XGNotification();
notific.setMsg_id(notifiShowedRlt.getMsgId());
notific.setTitle(notifiShowedRlt.getTitle());
notific.setContent(notifiShowedRlt.getContent());
// notificationActionType==1为Activity2为url3为intent
notific.setNotificationActionType(notifiShowedRlt
.getNotificationActionType());
// Activity,url,intent都可以通过getActivity()获得
notific.setActivity(notifiShowedRlt.getActivity());
notific.setUpdate_time(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
.format(Calendar.getInstance().getTime()));
NotificationService.getInstance(context).save(notific);
Intent testIntent = new Intent(TEST_ACTION);
if (notifiShowedRlt.getTitle().equals(Constants.LOCAL_NOTIFICATION_TITLE)) {
testIntent.putExtra("step", Constants.TEST_LOCAL_NOTIFICATION);
} else {
testIntent.putExtra("step", Constants.TEST_NOTIFICATION);
}
context.sendBroadcast(testIntent);
Intent viewIntent = new Intent(UPDATE_LISTVIEW_ACTION);
context.sendBroadcast(viewIntent);
show(context, "您有1条新消息, " + "通知被展示 " + notifiShowedRlt.toString());
Log.d(LogTag, "您有1条新消息, " + "通知被展示 " + notifiShowedRlt.toString() + ", PushChannel:" + notifiShowedRlt.getPushChannel());
}
/**
* 注册回调
*
* @param context
* @param errorCode 0 为成功,其它为错误码
*/
@Override
public void onRegisterResult(Context context, int errorCode, XGPushRegisterResult message) {
if (context == null || message == null) {
return;
}
String text = "";
if (errorCode == XGPushBaseReceiver.SUCCESS) {
// 在这里拿token
String token = message.getToken();
text = "注册成功1. token" + token;
} else {
text = message + "注册失败,错误码:" + errorCode;
}
Log.d(LogTag, text);
show(context, text);
}
/**
* 反注册回调
*
* @param context
* @param errorCode 0 为成功,其它为错误码
*/
@Override
public void onUnregisterResult(Context context, int errorCode) {
if (context == null) {
return;
}
String text = "";
if (errorCode == XGPushBaseReceiver.SUCCESS) {
text = "反注册成功";
} else {
text = "反注册失败" + errorCode;
}
Log.d(LogTag, text);
show(context, text);
}
/**
* 设置标签回调
*
* @param context
* @param errorCode 0 为成功,其它为错误码
* @param tagName 设置的 TAG
*/
@Override
public void onSetTagResult(Context context, int errorCode, String tagName) {
if (context == null) {
return;
}
String text = "";
if (errorCode == XGPushBaseReceiver.SUCCESS) {
text = "\"" + tagName + "\"设置成功";
} else {
text = "\"" + tagName + "\"设置失败,错误码:" + errorCode;
}
Log.d(LogTag, text);
show(context, text);
Intent testIntent = new Intent(TEST_ACTION);
testIntent.putExtra("step", Constants.TEST_SET_TAG);
context.sendBroadcast(testIntent);
}
/**
* 删除标签的回调
*
* @param context
* @param errorCode 0 为成功,其它为错误码
* @param tagName 设置的 TAG
*/
@Override
public void onDeleteTagResult(Context context, int errorCode, String tagName) {
if (context == null) {
return;
}
String text = "";
if (errorCode == XGPushBaseReceiver.SUCCESS) {
text = "\"" + tagName + "\"删除成功";
} else {
text = "\"" + tagName + "\"删除失败,错误码:" + errorCode;
}
Log.d(LogTag, text);
show(context, text);
Intent testIntent = new Intent(TEST_ACTION);
testIntent.putExtra("step", Constants.TEST_DEL_TAG);
context.sendBroadcast(testIntent);
}
/**
* 设置账号回调
*
* @param context
* @param errorCode 0 为成功,其它为错误码
* @param account 设置的账号
*/
@Override
public void onSetAccountResult(Context context, int errorCode, String account) {
Intent testIntent = new Intent(TEST_ACTION);
testIntent.putExtra("step", Constants.TEST_SET_ACCOUNT);
context.sendBroadcast(testIntent);
}
/**
* 删除账号回调
*
* @param context
* @param errorCode 0 为成功,其它为错误码
* @param account 设置的账号
*/
@Override
public void onDeleteAccountResult(Context context, int errorCode, String account) {
Intent testIntent = new Intent(TEST_ACTION);
testIntent.putExtra("step", Constants.TEST_DEL_ACCOUNT);
context.sendBroadcast(testIntent);
}
@Override
public void onSetAttributeResult(Context context, int i, String s) {
}
@Override
public void onDeleteAttributeResult(Context context, int i, String s) {
}
@Override
public void onQueryTagsResult(Context context, int errorCode, String data, String operateName) {
Log.i(LogTag, "action - onQueryTagsResult, errorCode:" + errorCode + ", operateName:" + operateName + ", data: " + data);
}
/**
* 通知点击回调 actionType=1为该消息被清除actionType=0为该消息被点击
*
* @param context
* @param message 包含被点击通知的内容
*/
@Override
public void onNotificationClickedResult(Context context, XGPushClickedResult message) {
if (context == null || message == null) {
return;
}
String text = "";
if (message.getActionType() == NotificationAction.clicked.getType()) {
// 通知在通知栏被点击啦。。。。。
// APP自己处理点击的相关动作
// 这个动作可以在activity的onResume也能监听请看第3点相关内容
text = "通知被打开 :" + message;
} else if (message.getActionType() == NotificationAction.delete.getType()) {
// 通知被清除啦。。。。
// APP自己处理通知被清除后的相关动作
text = "通知被清除 :" + message;
}
Toast.makeText(context, "广播接收到通知被点击:" + message.toString(),
Toast.LENGTH_SHORT).show();
// 获取自定义key-value
String customContent = message.getCustomContent();
if (customContent != null && customContent.length() != 0) {
JsonObject obj = JsonParser.parseString(customContent).getAsJsonObject();
// key1为前台配置的key
if (!TextUtils.isEmpty(obj.get("key").getAsString())) {
String value = obj.get("key").getAsString();
Log.d(LogTag, "get custom value:" + value);
}
// ...
}
// APP自主处理的过程。。。
Log.d(LogTag, text);
show(context, text);
}
private void show(Context context, String text) {
// Toast.makeText(context, text, Toast.LENGTH_SHORT).show();
}
private void processCustomMessage(Context context, XGPushTextMessage message) {
if (context == null || message == null) {
return;
}
String title = message.getTitle();
String content = message.getContent();
JsonObject extrasJson = JsonParser.parseString(content).getAsJsonObject();
String extras = "";
if (extrasJson.get("extras") != null) {
extras = extrasJson.get("extras").toString();
}
// PushManager.getInstance().setPushContent(title, extras);
}
}

View File

@@ -1,4 +1,4 @@
package com.fuying.sn.tpush.common;
package com.fuying.sn.push.tpush.common;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

View File

@@ -1,11 +1,11 @@
package com.fuying.sn.tpush.common;
package com.fuying.sn.push.tpush.common;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import com.fuying.sn.tpush.po.XGNotification;
import com.fuying.sn.push.tpush.po.XGNotification;
import java.util.ArrayList;
import java.util.List;

View File

@@ -1,4 +1,4 @@
package com.fuying.sn.tpush.po;
package com.fuying.sn.push.tpush.po;
public class XGNotification {
private Integer id;

View File

@@ -98,18 +98,19 @@ public class MainService extends BaseRxService implements MainSContact.MainView,
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
@Override
public void run() {
// if (JGYUtils.getInstance().isScreenOn()) {
Log.e(TAG, "getSnInfo1");
NetInterfaceManager.getInstance().getAppWhiteList(() -> {
Log.e("onConnected", "onNext: getAppWhiteList");
});
mPresenter.getSnInfo();
mPresenter.getAppAndWhite();
NetInterfaceManager.getInstance().updateAdminInfo();
NetInterfaceManager.getInstance().SendAppInstallInfo();
SPUtils.put(MainService.this, CommonConfig.JGY_FIRST_BOOT, 1);
tPushInit();
// }
// TODO: 2025/11/11 不确定某些机型状态获取是否正常
if (JGYUtils.getInstance().isScreenOn()) {
Log.e(TAG, "getSnInfo1");
NetInterfaceManager.getInstance().getAppWhiteList(() -> {
Log.e("onConnected", "onNext: getAppWhiteList");
});
mPresenter.getSnInfo();
mPresenter.getAppAndWhite();
NetInterfaceManager.getInstance().updateAdminInfo();
NetInterfaceManager.getInstance().SendAppInstallInfo();
SPUtils.put(MainService.this, CommonConfig.JGY_FIRST_BOOT, 1);
tPushInit();
}
}
}, 15000);
mMMKV.encode(CommonConfig.DEVICES_REBOOT, false);