英文:
How to send Huawei push notification through Proxy using Java
问题
如何通过代理服务器使用Java向华为设备发送推送通知
HttpPost httpPost = new HttpPost(this.HcmPushUrl);
StringEntity entity = new StringEntity(JSON.toJSONString(map), "UTF-8");
httpPost.setHeader("Authorization", "Bearer " + accessToken);
httpPost.setHeader("Content-Type", "application/json;charset=utf-8");
httpPost.setEntity(entity);
CloseableHttpResponse response = httpClient.execute(httpPost);
String rpsContent = EntityUtils.toString(response.getEntity());
这与APNS调用中的ProxyManager.setProxy(proxyAddress, proxyPort)类似。
英文:
How to send push notification for Huawei devices using Java through proxy server
HttpPost httpPost = new HttpPost(this.HcmPushUrl);
StringEntity entity = new StringEntity(JSON.toJSONString(map), "UTF-8");
httpPost.setHeader("Authorization", "Bearer " + accessToken);
httpPost.setHeader("Content-Type", "application/json;charset=utf-8");
httpPost.setEntity(entity);
CloseableHttpResponse response = httpClient.execute(httpPost);
String rpsContent = EntityUtils.toString(response.getEntity());
Which is something similar to ProxyManager.setProxy(proxyAddress, proxyPort) of APNS call.
答案1
得分: 1
请参考以下代码:
HuaweiCredential credential = HuaweiCredential.builder()
.setAppId(appId)
.setAppSecret(appSecret)
.setHttpClient()//在这里设置您自己的带有代理的 http 客户端
.build();
// 创建 HuaweiOption
HuaweiOption option = HuaweiOption.builder()
.setCredential(credential)
.setHttpClient()//在这里设置您自己的带有代理的 http 客户端
.build();
HMS Pushkit Java 服务器演示位于 Github
英文:
Please kindly refer to the following code:
HuaweiCredential credential = HuaweiCredential.builder()
.setAppId(appId)
.setAppSecret(appSecret)
.setHttpClient()//set your own http client with proxy here
.build();
// Create HuaweiOption
HuaweiOption option = HuaweiOption.builder()
.setCredential(credential)
.setHttpClient()//set your own http client with proxy here
.build();
HMS Pushkit Java Severdemo On Github
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论