public void registerPushServicesWithToken(final String token){
  String httpURI;
  String httpMethod;
  JSONObject data=new JSONObject();
  try {
    data.put("token",token);
    data.put("service","google");
    SharedPreferences prefs=appContext.getSharedPreferences(appContext.getPackageName(),Context.MODE_PRIVATE);
    if (null != prefs) {
      String lastKnownPushToken=prefs.getString(PROPERTY_LAST_VALID_PUSH_TOKEN,"notAvailable");
      String lastKnownPushTokenID=prefs.getString(PROPERTY_LAST_VALID_PUSH_TOKEN_ID,"notAvailable");
      if ((null == lastKnownPushTokenID) || (lastKnownPushTokenID.equals("notAvailable"))) {
        httpURI=String.format("/v1/connections/%s/push-token",localConnectionID);
        httpMethod="post";
        createOrUpdatePushServiceToken(token,httpURI,httpMethod,data,prefs);
      }
 else       if (!lastKnownPushToken.equals("notAvailable") && !lastKnownPushToken.equals(token)) {
        httpURI=String.format("/v1/connections/%s/push-token/%s",localConnectionID,lastKnownPushTokenID);
        httpMethod="put";
        createOrUpdatePushServiceToken(token,httpURI,httpMethod,data,prefs);
      }
    }
  }
 catch (  JSONException e) {
    Log.d("","Invalid JSON format for token");
  }
}

public void registerPushServicesWithToken ( final String token ) { String httpURI ; String httpMethod ; JSONObject data = new JSONObject ( ) ; try { data . put ( "token" , token ) ; data . put ( "service" , "google" ) ; SharedPreferences prefs = appContext . getSharedPreferences ( appContext . getPackageName ( ) , Context . MODE_PRIVATE ) ; if ( null != prefs ) { String lastKnownPushToken = prefs . getString ( PROPERTY_LAST_VALID_PUSH_TOKEN , "notAvailable" ) ; String lastKnownPushTokenID = prefs . getString ( PROPERTY_LAST_VALID_PUSH_TOKEN_ID , "notAvailable" ) ; if ( ( null == lastKnownPushTokenID ) || ( lastKnownPushTokenID . equals ( "notAvailable" ) ) ) { httpURI = String . format ( "/v1/connections/%s/push-token" , localConnectionID ) ; httpMethod = "post" ; createOrUpdatePushServiceToken ( token , httpURI , httpMethod , data , prefs ) ; } else if ( ! lastKnownPushToken . equals ( "notAvailable" ) && ! lastKnownPushToken . equals ( token ) ) { httpURI = String . format ( "/v1/connections/%s/push-token/%s" , localConnectionID , lastKnownPushTokenID ) ; httpMethod = "put" ; createOrUpdatePushServiceToken ( token , httpURI , httpMethod , data , prefs ) ; } } } catch ( JSONException e ) { Log . d ( "" , "Invalid JSON format for token" ) ; } }
register the client to receive push notifications when the socket is not active
