public void subscribe ( final String tagName , final MFPPushResponseListener < String > listener ) { if ( isAbleToSubscribe ( ) ) { MFPPushUrlBuilder builder = new MFPPushUrlBuilder ( applicationId ) ; String path = builder . getSubscriptionsUrl ( ) ; logger . debug ( "MFPPush:subscribe() - The tag subscription path is: " + path ) ; MFPPushInvoker invoker = MFPPushInvoker . newInstance ( appContext , path , Request . POST , clientSecret ) ; invoker . setJSONRequestBody ( buildSubscription ( tagName ) ) ; invoker . setResponseListener ( new ResponseListener ( ) { @ Override public void onSuccess ( Response response ) { //Subscription successfully created. logger . info ( "MFPPush:subscribe() - Tag subscription successfully created. The response is: " + response . toString ( ) ) ; listener . onSuccess ( tagName ) ; } @ Override public void onFailure ( Response response , Throwable throwable , JSONObject jsonObject ) { //Error while subscribing to tags. logger . error ( "MFPPush: Error while subscribing to tags" ) ; listener . onFailure ( getException ( response , throwable , jsonObject ) ) ; } } ) ; invoker . execute ( ) ; } }
Subscribes to the given tag