version:2.1

fix:完善推送
update:
This commit is contained in:
2022-01-25 16:12:36 +08:00
parent a432526311
commit edf23945b5
36 changed files with 2692 additions and 945 deletions

View File

@@ -49,6 +49,8 @@ import com.aoleyun.sn.utils.ForegroundAppUtil;
import com.aoleyun.sn.utils.SPUtils;
import com.aoleyun.sn.utils.TimeUtils;
import com.aoleyun.sn.utils.Utils;
import com.tencent.android.tpush.XGIOperateCallback;
import com.tencent.android.tpush.XGPushManager;
import com.tencent.mmkv.MMKV;
import java.io.IOException;
@@ -69,8 +71,8 @@ import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
import static com.aoleyun.sn.jpush.TagAliasOperatorHelper.ACTION_SET;
import static com.aoleyun.sn.jpush.TagAliasOperatorHelper.sequence;
//import static com.aoleyun.sn.jpush.TagAliasOperatorHelper.ACTION_SET;
//import static com.aoleyun.sn.jpush.TagAliasOperatorHelper.sequence;
public class HTTPInterface {
private static final String TAG = HTTPInterface.class.getSimpleName();
@@ -100,13 +102,13 @@ public class HTTPInterface {
}
}
synchronized public static void setJpushTags(final Context context) {
synchronized public static void setPushTags(final Context context) {
NetInterfaceManager.getInstance()
.getJpushTagsObservable()
.subscribe(new Observer<BaseResponse>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
Log.e(TAG + ":" + "setJpushTags", "onSubscribe: ");
Log.e(TAG + ":" + "setPushTags", "onSubscribe: ");
}
@Override
@@ -114,7 +116,7 @@ public class HTTPInterface {
if (response.code == 200) {
JsonObject jsonObject = JsonParser.parseString(new Gson().toJson(response.data)).getAsJsonObject();
String batch = jsonObject.get("batch").getAsString();
Log.e(TAG + ":" + "setJpushTags", "onNext: " + batch);
Log.e(TAG + ":" + "setPushTags", "onNext: " + batch);
if (!TextUtils.isEmpty(batch)) {
Set set = new HashSet();
set.add(batch);
@@ -128,36 +130,48 @@ public class HTTPInterface {
}
}
});
setTag(context, set);
Set<String> tagsSet = new HashSet<>(set);
XGPushManager.clearAndAppendTags(context, "clearAndAppendTags :" + System.currentTimeMillis(), tagsSet, new XGIOperateCallback() {
@Override
public void onSuccess(Object o, int i) {
Log.e("setPushTags", "onSuccess: " + o);
}
@Override
public void onFail(Object o, int i, String s) {
Log.e("setPushTags", "onFail: " + o);
}
});
// setTag(context, set);
} else {
Log.e(TAG + ":" + "setJpushTags", "onNext: " + "batch empty");
Log.e(TAG + ":" + "setPushTags", "onNext: " + "batch empty");
}
} else {
Log.e(TAG + ":" + "setJpushTags", "onNext: " + response.toString());
Log.e(TAG + ":" + "setPushTags", "onNext: " + response.toString());
}
}
@Override
public void onError(@NonNull Throwable e) {
Log.e(TAG + ":" + "setJpushTags", "onError: " + e.getMessage());
Log.e(TAG + ":" + "setPushTags", "onError: " + e.getMessage());
onComplete();
}
@Override
public void onComplete() {
Log.e(TAG + ":" + "setJpushTags", "onComplete: ");
Log.e(TAG + ":" + "setPushTags", "onComplete: ");
}
});
}
private static void setTag(Context context, Set set) {
TagAliasOperatorHelper.TagAliasBean tagAliasBean = new TagAliasOperatorHelper.TagAliasBean();
tagAliasBean.action = ACTION_SET;
sequence++;
tagAliasBean.tags = set;
tagAliasBean.isAliasAction = false;
TagAliasOperatorHelper.getInstance().handleAction(context, sequence, tagAliasBean);
}
// private static void setTag(Context context, Set set) {
// TagAliasOperatorHelper.TagAliasBean tagAliasBean = new TagAliasOperatorHelper.TagAliasBean();
// tagAliasBean.action = ACTION_SET;
// sequence++;
// tagAliasBean.tags = set;
// tagAliasBean.isAliasAction = false;
// TagAliasOperatorHelper.getInstance().handleAction(context, sequence, tagAliasBean);
// }
public interface GetAppinsideWebCallback {
void onComplete();
@@ -802,28 +816,28 @@ public class HTTPInterface {
.subscribe(new Observer<NetAndLaunchBean>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
Log.e("getAppAutoStartUpdateAndNet", "onSubscribe: ");
Log.e("getAutoUpdateAndNet", "onSubscribe: ");
}
@Override
public void onNext(@NonNull NetAndLaunchBean netAndLaunchBean) {
Log.e("getAppAutoStartUpdateAndNet", "onNext: " + netAndLaunchBean.toString());
Log.e("getAutoUpdateAndNet", "onNext: " + netAndLaunchBean.toString());
if (netAndLaunchBean.getCode() == 200) {
JGYUtils.getInstance().setNetAndlaunch(netAndLaunchBean, appListInfos);
} else {
Log.e("getAppAutoStartUpdateAndNet", "onNext: " + netAndLaunchBean.toString());
Log.e("getAutoUpdateAndNet", "onNext: " + netAndLaunchBean.toString());
}
}
@Override
public void onError(@NonNull Throwable e) {
Log.e("getAppAutoStartUpdateAndNet", "onError: " + e.getMessage());
Log.e("getAutoUpdateAndNet", "onError: " + e.getMessage());
onComplete();
}
@Override
public void onComplete() {
Log.e("getAppAutoStartUpdateAndNet", "onComplete: ");
Log.e("getAutoUpdateAndNet", "onComplete: ");
}
});
}

View File

@@ -58,6 +58,7 @@ import com.aoleyun.sn.network.api.newapi.SnTimeControlApi;
import com.aoleyun.sn.network.api.newapi.StudentsInfosApi;
import com.aoleyun.sn.network.api.newapi.TopAppControlApi;
import com.aoleyun.sn.network.api.newapi.UpdateDeviceInfoApi;
import com.aoleyun.sn.utils.JGYUtils;
import com.aoleyun.sn.utils.MD5Util;
import com.aoleyun.sn.utils.SPUtils;
import com.aoleyun.sn.utils.Utils;
@@ -70,7 +71,6 @@ import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import cn.jpush.android.api.JPushInterface;
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
@@ -265,7 +265,8 @@ public class NetInterfaceManager {
return mRetrofit.create(MACAddressApi.class)
.sendMACaddress(Utils.getSerial(),
Utils.getAndroid10MAC(mContext),
JPushInterface.getRegistrationID(mContext),
"0000",
// JPushInterface.getRegistrationID(mContext),
Utils.getCustomVersion(),
BuildConfig.VERSION_NAME,
Utils.getAPPVersionName(PackageNames.APPSTORE, mContext),
@@ -277,7 +278,8 @@ public class NetInterfaceManager {
Utils.getBluetoothList(),
Utils.getWifiAlias(mContext),
Utils.getAPPVersionName(PackageNames.BROWSER, mContext),
Utils.getAPPVersionName(PackageNames.NOTIFICATIONS, mContext)
Utils.getAPPVersionName(PackageNames.NOTIFICATIONS, mContext),
JGYUtils.getInstance().getAppPlatform()
)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());

View File

@@ -3,6 +3,8 @@ package com.aoleyun.sn.network.api.newapi;
import com.aoleyun.sn.bean.BaseResponse;
import com.aoleyun.sn.network.UrlAddress;
import java.io.File;
import io.reactivex.Observable;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
@@ -26,6 +28,7 @@ public interface MACAddressApi {
@Field("bluetooth") String bluetooth,
@Field("wifi_name") String wifi_name,
@Field("browser_version") String browser_version,
@Field("notice_version") String notice_version
@Field("notice_version") String notice_version,
@Field("platform") String platform
);
}