Skip to content
This repository has been archived by the owner on Oct 29, 2021. It is now read-only.

Commit

Permalink
fix:修复华为注册回调问题
Browse files Browse the repository at this point in the history
  • Loading branch information
hackycy committed Apr 22, 2020
1 parent 6bdcb40 commit 60d19bd
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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厂商自己的推送服务进行集成,并统一管理,使用前还是需要熟悉各个平台的相关文档

Expand Down
2 changes: 1 addition & 1 deletion oscvpush/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private String getAppId() {
}

/**
* 华为推送服务注册
* 华为推送服务注册, 有可能会回调两次onRegister
* @param callback
*/
public void register(IPushCallback callback) {
Expand All @@ -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();
Expand All @@ -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
Expand Down

0 comments on commit 60d19bd

Please sign in to comment.