我们正在使用Mobile平台制作一个混合应用程序。对于推送通知,我们将使用Unicast通知。我找不到任何关于取消订阅的文档。有谁能帮助我知道如何在Unicast通知场景中取消订阅用户的推送通知呢?
发布于 2016-01-02 21:36:45
我找到了取消订阅Unicast通知的方法。不知道这是不是正确的方法,但它对我有用。我使用了REST运行时服务
用于在MobileFirst运行时环境中推送的REST允许部署在MobileFirst服务器之外的后端服务器应用程序从REST端点访问推送功能。
虽然它是为后端服务器设计的,但它适用于我。
String token = getToken("unregister-device");首先获取令牌关于如何获取令牌的详细信息是这里
获得令牌后,实现rest客户端,检查文档这里
样本代码。
HttpClient httpClient = HttpClientBuilder.create().build();
HttpDelete postRequest = new HttpDelete("http://localhost:10080/MyProject/imfpush/v1/apps/MyMobileApp/devices/12121-1212121-121212-12121");
postRequest.addHeader("Content-Type", "application/json");
postRequest.addHeader("Authorization", "Bearer "+token);
HttpResponse response = httpClient.execute(postRequest);
if (response.getStatusLine().getStatusCode() != 204) {
throw new RuntimeException("Failed : HTTP error code : " + response.getStatusLine().getStatusCode());
}
BufferedReader br = new BufferedReader(new InputStreamReader((response.getEntity().getContent())));
String output;
System.out.println("============Output:============");
while ((output = br.readLine()) != null) {
System.out.println(output);
}https://stackoverflow.com/questions/34519253
复制相似问题