private String getOldToken ( Context appContext ) { String jsonData = preferenceProvider . get ( appContext ) . getString ( String . format ( REGISTRAR_PREFERENCE_TEMPLATE , senderId ) , "" ) ; if ( jsonData . isEmpty ( ) ) { return "" ; } JsonObject jsonedPreferences = new JsonParser ( ) . parse ( jsonData ) . getAsJsonObject ( ) ; try { return jsonedPreferences . get ( "deviceToken" ) . getAsString ( ) ; } catch ( Exception ignore ) { //There was something wrong with the deviceToken or the jsonPreferences. //This probably means that there isn't an oldToken. Let's log and return an empty String Log . w ( TAG , ignore . getMessage ( ) , ignore ) ; return "" ; } }
Returns the most recently used deviceToken