diff --git a/package.json b/package.json index a7cc2f042..0bf4f0227 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-plugin-firebasex", - "version": "16.5.1-hogangnono", + "version": "16.5.2-hogangnono", "description": "Cordova plugin for Google Firebase", "types": "./types/index.d.ts", "author": { diff --git a/plugin.xml b/plugin.xml index af7be0a41..2b1e8814f 100644 --- a/plugin.xml +++ b/plugin.xml @@ -1,5 +1,5 @@ -() { - @Override - public void onSuccess(GetTokenResult result) { - try { - String idToken = result.getToken(); - if (idToken != null && idToken.equals(instance.currentIdToken)) { - return; + if (user != null) { + user.getIdToken(true).addOnSuccessListener(new OnSuccessListener() { + @Override + public void onSuccess(GetTokenResult result) { + try { + String idToken = result.getToken(); + if (idToken != null && idToken.equals(instance.currentIdToken)) { + return; + } + instance.currentIdToken = idToken; + String providerId = result.getSignInProvider(); + FirebasePlugin.instance.executeGlobalJavascript(JS_GLOBAL_NAMESPACE + "_onAuthIdTokenChange({\"idToken\":\"" + idToken + "\",\"providerId\":\"" + providerId + "\"})"); + } catch (Exception e) { + FirebasePlugin.instance.executeGlobalJavascript(JS_GLOBAL_NAMESPACE + "_onAuthIdTokenChange()"); } - instance.currentIdToken = idToken; - String providerId = result.getSignInProvider(); - FirebasePlugin.instance.executeGlobalJavascript(JS_GLOBAL_NAMESPACE + "_onAuthIdTokenChange({\"idToken\":\"" + idToken + "\",\"providerId\":\"" + providerId + "\"})"); - } catch (Exception e) { - FirebasePlugin.instance.executeGlobalJavascript(JS_GLOBAL_NAMESPACE + "_onAuthIdTokenChange()"); } - } - }).addOnFailureListener(new OnFailureListener() { - @Override - public void onFailure(@NonNull Exception e) { - FirebasePlugin.instance.executeGlobalJavascript(JS_GLOBAL_NAMESPACE + "_onAuthIdTokenChange()"); - } - }); + }).addOnFailureListener(new OnFailureListener() { + @Override + public void onFailure(@NonNull Exception e) { + FirebasePlugin.instance.executeGlobalJavascript(JS_GLOBAL_NAMESPACE + "_onAuthIdTokenChange()"); + } + }); + } } catch (Exception e) { handleExceptionWithoutContext(e); }