public void unregisterFromPushServices ( final Respoke . TaskCompletionListener completionListener ) { if ( isConnected ( ) ) { SharedPreferences prefs = appContext . getSharedPreferences ( appContext . getPackageName ( ) , Context . MODE_PRIVATE ) ; if ( null != prefs ) { String lastKnownPushTokenID = prefs . getString ( PROPERTY_LAST_VALID_PUSH_TOKEN_ID , "notAvailable" ) ; if ( ( null != lastKnownPushTokenID ) && ! lastKnownPushTokenID . equals ( "notAvailable" ) ) { // A push token has previously been registered successfully String httpURI = String . format ( "/v1/connections/%s/push-token/%s" , localConnectionID , lastKnownPushTokenID ) ; signalingChannel . sendRESTMessage ( "delete" , httpURI , null , new RespokeSignalingChannel . RESTListener ( ) { @ Override public void onSuccess ( Object response ) { // Remove the push token ID from shared memory so that push may be registered again in the future SharedPreferences prefs = appContext . getSharedPreferences ( appContext . getPackageName ( ) , Context . MODE_PRIVATE ) ; SharedPreferences . Editor editor = prefs . edit ( ) ; editor . remove ( PROPERTY_LAST_VALID_PUSH_TOKEN_ID ) ; editor . apply ( ) ; Respoke . postTaskSuccess ( completionListener ) ; } @ Override public void onError ( String errorMessage ) { Respoke . postTaskError ( completionListener , "Error unregistering push service token: " + errorMessage ) ; } } ) ; } else { Respoke . postTaskSuccess ( completionListener ) ; } } else { Respoke . postTaskError ( completionListener , "Unable to access shared preferences to look for push token" ) ; } } else { Respoke . postTaskError ( completionListener , "Can't complete request when not connected. Please reconnect!" ) ; } }
Unregister this client from the push service so that no more notifications will be received for this endpoint ID