From 60d19bd01d4d8d6dcb28f3ac48e44cd6f6010343 Mon Sep 17 00:00:00 2001 From: hackycy Date: Wed, 22 Apr 2020 21:11:25 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E5=A4=8D=E5=8D=8E?= =?UTF-8?q?=E4=B8=BA=E6=B3=A8=E5=86=8C=E5=9B=9E=E8=B0=83=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/misc.xml | 2 +- README.md | 2 +- oscvpush/build.gradle | 2 +- .../siyee/oscvpush/huawei/HWPushRegister.java | 24 ++++++++++++++++--- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index dfd2c79..37a7509 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + diff --git a/README.md b/README.md index 6ede204..f5fcd13 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # 简介 -![](https://img.shields.io/badge/release-v1.0.9-green) +![](https://img.shields.io/badge/release-v1.1.0-green) 更方便的将各个rom厂商自己的推送服务进行集成,并统一管理,使用前还是需要熟悉各个平台的相关文档 diff --git a/oscvpush/build.gradle b/oscvpush/build.gradle index a46dc97..4bc1909 100644 --- a/oscvpush/build.gradle +++ b/oscvpush/build.gradle @@ -9,7 +9,7 @@ android { minSdkVersion 19 targetSdkVersion 29 versionCode 14 - versionName "1.0.9" + versionName "1.1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } diff --git a/oscvpush/src/main/java/com/siyee/oscvpush/huawei/HWPushRegister.java b/oscvpush/src/main/java/com/siyee/oscvpush/huawei/HWPushRegister.java index 505f405..0a65955 100644 --- a/oscvpush/src/main/java/com/siyee/oscvpush/huawei/HWPushRegister.java +++ b/oscvpush/src/main/java/com/siyee/oscvpush/huawei/HWPushRegister.java @@ -85,7 +85,7 @@ private String getAppId() { } /** - * 华为推送服务注册 + * 华为推送服务注册, 有可能会回调两次onRegister * @param callback */ public void register(IPushCallback callback) { @@ -98,9 +98,16 @@ public void register(IPushCallback callback) { @Override public void run() { try { - HmsInstanceId.getInstance(mContext).getToken(getAppId(), HCM); + String token = HmsInstanceId.getInstance(mContext).getToken(getAppId(), HCM); + if (NullUtils.checkNull(token)) { + HWPushRegister.getPushCallback().onRegister(PushConstants.UNKNOWN_CODE, null); + return; + } + LogUtils.e(token); + HWPushRegister.getPushCallback().onRegister(PushConstants.SUCCESS_CODE, Token.buildToken(Target.HUAWEI, token)); } catch (ApiException e) { LogUtils.e(e.getMessage()); + HWPushRegister.getPushCallback().onRegister(PushConstants.UNKNOWN_CODE, null); } } }.start(); @@ -109,7 +116,18 @@ public void run() { @Override public void unregister() { - + new Thread(new Runnable() { + @Override + public void run() { + try { + HmsInstanceId.getInstance(mContext).deleteToken(getAppId(), HCM); + HWPushRegister.getPushCallback().onUnRegister(PushConstants.SUCCESS_CODE); + } catch (ApiException e) { + LogUtils.e(e.getMessage()); + HWPushRegister.getPushCallback().onUnRegister(PushConstants.UNKNOWN_CODE); + } + } + }).start(); } @Override