From 741d45e6603e1a7e01d4a5977c2f1f1ac6833ca8 Mon Sep 17 00:00:00 2001 From: fcamblor Date: Mon, 13 Jun 2022 22:57:50 +0200 Subject: [PATCH] fixing error during initSession() (it was only working the first time it was called in the whole application life, see https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking-attribution/issues/653) --- src/android/io/branch/BranchSDK.java | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/android/io/branch/BranchSDK.java b/src/android/io/branch/BranchSDK.java index 97dddfd8..bf9e3255 100644 --- a/src/android/io/branch/BranchSDK.java +++ b/src/android/io/branch/BranchSDK.java @@ -867,14 +867,18 @@ public void onInitFinished(JSONObject referringParams, BranchError error) { this._callbackContext.success(referringParams); } } else { - JSONObject message = new JSONObject(); - try { - message.put("error", error.getMessage()); - } catch (JSONException e) { - e.printStackTrace(); - } - if (this._callbackContext != null) { - this._callbackContext.error(message); + if (error.getErrorCode() == BranchError.ERR_BRANCH_ALREADY_INITIALIZED) { + getLatestReferringParams(this._callbackContext); + } else { + JSONObject message = new JSONObject(); + try { + message.put("error", error.getMessage()); + } catch (JSONException e) { + e.printStackTrace(); + } + if (this._callbackContext != null) { + this._callbackContext.error(message); + } } }