0

We are making an hybrid application Using Mobile First Platform. For push notification we will be using Unicast notifications. I could not find any documentation regarding unsubscription. Can any one help me to know how can I unsubscribe user from push notification in Unicast Notification scenario.

2 Answers 2

1

Check the official documentation here, It says:

The userId(s) must be the user IDs that were used to subscribe to the push notification event source.

Which suggests that unicast notifications uses a the same event-source subscription/unsubscription mechanisms, check the official documentation here for how to unsubscribe from an event source.

6
  • Correct me if I am wrong but the difference between Unicast and Event source is that their is no event source ID in Unicast scenario. In our current application we simply use WL.Client.connect() to subscribe the user for Push. If the mechanisms is same as Event source then what will be the alias name. Check this doc it explains unscuscription process, it ask for mandatory alias name. www-01.ibm.com/support/knowledgecenter/SSHS8R_7.1.0/… Dec 31, 2015 at 5:56
  • what should I put in alias name, is there any default event source ID assigned while user subscription process? Dec 31, 2015 at 5:59
  • You are right, unicast notifications are different from event source based notifications and the documentation line I used to understand it was misleading. I am doing a sample app to learn how to unsubscribe from unicast notifications. I think It works very much like tag notifications (using the same WL.Server.sendMessage with different parms) so it might have a special tag that you can unsubscribe from (like broadcast messages having the special tag Push.ALL). I will let you know what I reach. Also if you can explain your business requirement, might be able to help you with it.
    – Hisham
    Dec 31, 2015 at 14:20
  • Our requirement is to send push notification to users based on your case status. So each user will have different status. For this requirement we decided to go with Unicast notifications. Dec 31, 2015 at 14:46
  • Can you explain why this requirement can't be implemented using event source notifications?
    – Hisham
    Dec 31, 2015 at 17:17
0

I found the way to unsubscribe from Unicast Notification. Not sure if this is the right way but it works for me. I used REST API Runtime Services

The REST API for Push in the MobileFirst runtime environment enables back-end server applications that were deployed outside of the MobileFirst Server to access Push functions from a REST API endpoint.

Thought it is designed for backend server it works for me.

String  token = getToken("unregister-device");

First get the token the details about how to get the token is here

Once you get the token then implement the rest client check the documentation here

Sample code.

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);
        }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.