|
|
@@ -46,7 +46,7 @@ public class CommonPushVendorHttpClient {
|
|
|
/** 荣耀 Push API */
|
|
|
private static final String HONOR_PUSH_API_BASE = "https://push-api.cloud.honor.com";
|
|
|
private static final String HONOR_AUTH_URL =
|
|
|
- "https://auth.honor.com/auth/realms/developer/protocol/openid-connect/token";
|
|
|
+ "https://iam.developer.honor.com/auth/token";
|
|
|
/** 华为推送成功响应码 */
|
|
|
private static final String HUAWEI_SUCCESS_CODE = "80000000";
|
|
|
|
|
|
@@ -764,6 +764,7 @@ public class CommonPushVendorHttpClient {
|
|
|
return CommonPushVendorSendResult.fail();
|
|
|
}
|
|
|
String pushClientId = resolveHuaweiOAuthClientId(credential);
|
|
|
+ String projectId = resolveHuaweiProjectId(credential);
|
|
|
if (StringUtils.isBlank(pushClientId)) {
|
|
|
log.warn("华为推送缺少 clientId/appId, taskNo={}", task.getTaskNo());
|
|
|
return CommonPushVendorSendResult.fail();
|
|
|
@@ -796,6 +797,14 @@ public class CommonPushVendorHttpClient {
|
|
|
return parseHuaweiSendResult(sendResp, task.getTaskNo(), pushTokens.size());
|
|
|
}
|
|
|
|
|
|
+ private String resolveHuaweiProjectId(JSONObject credential) {
|
|
|
+ String projectId = StringUtils.trimToNull(credential.getString("projectId"));
|
|
|
+ if (projectId != null) {
|
|
|
+ return projectId;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
private CommonPushVendorSendResult sendHonorLike(JSONObject credential, CommonPushTask task, List<String> deviceIds) {
|
|
|
if (deviceIds == null || deviceIds.isEmpty()) {
|
|
|
return CommonPushVendorSendResult.fail();
|
|
|
@@ -923,7 +932,9 @@ public class CommonPushVendorHttpClient {
|
|
|
tokenForm.add("grant_type", "client_credentials");
|
|
|
tokenForm.add("client_id", appId);
|
|
|
tokenForm.add("client_secret", appSecret);
|
|
|
- String tokenResp = postForm(HONOR_AUTH_URL, tokenForm, null);
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
+ headers.put("Content-Type", "application/x-www-form-urlencoded");
|
|
|
+ String tokenResp = postForm(HONOR_AUTH_URL, tokenForm, headers);
|
|
|
JSONObject tokenJson = JSONObject.parseObject(tokenResp);
|
|
|
if (tokenJson == null || StringUtils.isBlank(tokenJson.getString("access_token"))) {
|
|
|
log.warn("荣耀鉴权失败: {}", tokenResp);
|
|
|
@@ -958,6 +969,8 @@ public class CommonPushVendorHttpClient {
|
|
|
clickAction.put("type", 3);
|
|
|
notification.put("click_action", clickAction);
|
|
|
android.put("notification", notification);
|
|
|
+ // TODO 设置 android 通知参数
|
|
|
+ android.put("category","IM");
|
|
|
message.put("android", android);
|
|
|
List<String> huaweiTokens = new ArrayList<>();
|
|
|
for (String pushToken : pushTokens) {
|
|
|
@@ -996,6 +1009,9 @@ public class CommonPushVendorHttpClient {
|
|
|
if (markerIndex >= 0) {
|
|
|
return trimmed.substring(markerIndex);
|
|
|
}
|
|
|
+ if(trimmed.contains("HUAWEI_CN_")){
|
|
|
+ return trimmed.substring(trimmed.indexOf("HUAWEI_CN_") + 10);
|
|
|
+ }
|
|
|
return trimmed;
|
|
|
}
|
|
|
|