public void unsubscribe ( final String tagName , final MFPPushResponseListener < String > listener ) { if ( isAbleToSubscribe ( ) ) { MFPPushUrlBuilder builder = new MFPPushUrlBuilder ( applicationId ) ; String path = builder . getSubscriptionsUrl ( deviceId , tagName ) ; if ( path == DEVICE_ID_NULL ) { listener . onFailure ( new MFPPushException ( "The device is not registered yet. Please register device before calling subscriptions API" ) ) ; return ; } logger . debug ( "MFPPush:unsubscribe() - The tag unsubscription path is: " + path ) ; MFPPushInvoker invoker = MFPPushInvoker . newInstance ( appContext , path , Request . DELETE , clientSecret ) ; invoker . setResponseListener ( new ResponseListener ( ) { @ Override public void onSuccess ( Response response ) { logger . info ( "MFPPush:unsubscribe() - Tag unsubscription successful. The response is: " + response . toString ( ) ) ; listener . onSuccess ( tagName ) ; } @ Override public void onFailure ( Response response , Throwable throwable , JSONObject jsonObject ) { //Error while Unsubscribing to tags. logger . error ( "MFPPush: Error while Unsubscribing to tags" ) ; listener . onFailure ( getException ( response , throwable , jsonObject ) ) ; } } ) ; invoker . execute ( ) ; } }
Unsubscribes to the given tag