@ Override public void unregister ( final Context context , final Callback < Void > callback ) { new AsyncTask < Void , Void , Exception > ( ) { @ Override protected Exception doInBackground ( Void ... params ) { try { if ( ( deviceToken == null ) || ( deviceToken . trim ( ) . equals ( "" ) ) ) { throw new IllegalStateException ( DEVICE_ALREADY_UNREGISTERED ) ; } if ( instanceId == null ) { instanceId = firebaseInstanceIdProvider . get ( context ) ; } String token = Tasks . await ( instanceId . getInstanceId ( ) , 30 , TimeUnit . SECONDS ) . getToken ( ) ; FirebaseMessaging firebaseMessaging = firebaseMessagingProvider . get ( context ) ; for ( String catgory : categories ) { firebaseMessaging . unsubscribeFromTopic ( catgory ) ; } //Unsubscribe to generic topic firebaseMessaging . unsubscribeFromTopic ( variantId ) ; instanceId . deleteInstanceId ( ) ; HttpProvider provider = httpProviderProvider . get ( deviceRegistryURL , TIMEOUT ) ; setPasswordAuthentication ( variantId , secret , provider ) ; try { provider . delete ( deviceToken ) ; deviceToken = "" ; removeSavedPostData ( context . getApplicationContext ( ) ) ; return null ; } catch ( HttpException ex ) { return ex ; } } catch ( Exception ex ) { return ex ; } } @ SuppressWarnings ( "unchecked" ) @ Override protected void onPostExecute ( Exception result ) { if ( result == null ) { callback . onSuccess ( null ) ; } else { callback . onFailure ( result ) ; } } } . execute ( ( Void ) null ) ; }
Unregister device from Unified Push Server .