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();
    }
  }
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 ) { 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 ) { logger . error ( "MFPPush: Error while subscribing to tags" ) ; listener . onFailure ( getException ( response , throwable , jsonObject ) ) ; } } ) ; invoker . execute ( ) ; } }
Subscribes to the given tag

@param tagName  name of the tag
@param listener Mandatory listener class. When the subscription is created
successfully the {@link MFPPushResponseListener}.onSuccess
method is called with the tagName for which subscription is
created. {@link MFPPushResponseListener}.onFailure method is
called otherwise