cordova-ionic-phonegap-branch-deep-linking-attribution icon indicating copy to clipboard operation
cordova-ionic-phonegap-branch-deep-linking-attribution copied to clipboard

Warning. Session initialization already happened. To force a new session, set intent extra, "branch_force_new_session", to true.

Open ShayShaked opened this issue 5 years ago • 2 comments
trafficstars

Hi, We're facing a problem with the latest release Cordova 4.1.3 . When the app is initialized, every resume we get this error what causes the app to work unexpectedly: error":"Warning. Session initialization already happened. To force a new session, set intent extra, "branch_force_new_session", to true.

I saw that the problem occurres also on android-branch-deep-linking-attribution , Android SDK v4.3.2. Is there any fix on the way?

env info Ionic:

Ionic CLI : 5.2.4 Ionic Framework : @ionic/angular 4.7.4 @angular-devkit/build-angular : 0.802.1 @angular-devkit/schematics : 8.2.1 @angular/cli : 8.2.1 @ionic/angular-toolkit : 2.0.0

Cordova:

Cordova CLI : 9.0.0 ([email protected])

Update 15/02/2021 There is an issue with location permission. When Location permission is Disabled the InitSession runs twice, what cause the Session initialization already happened error. If the Location permission is Enabled the initSession run only once

ShayShaked avatar Apr 26 '20 14:04 ShayShaked

We are facing the same issue with:

Cordova CLI: 9.0.0 cordova-android: 9.0.0 cordova-ios: 6.1.0

PDLMobileApps avatar Jul 17 '20 21:07 PDLMobileApps

Hello! I fixed this issue by replacing SessionListener.onInitFinished() method with next:

public void onInitFinished(JSONObject referringParams, BranchError error) {

            String out;

            if (error == null && referringParams != null) {
                if (this._callbackContext != null) {
                    this._callbackContext.success(referringParams);
                }
            } else {
                // fix ERR_BRANCH_ALREADY_INITIALIZED error
                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);
                    }
                }
            }
        }

mifkys avatar Jul 22 '20 05:07 mifkys