|
18 | 18 |
|
19 | 19 | import io.branch.referral.*; |
20 | 20 | import io.branch.referral.Branch.BranchLinkCreateListener; |
| 21 | +import io.branch.referral.BuildConfig; |
21 | 22 | import io.branch.referral.util.*; |
22 | 23 | import io.branch.referral.Branch; |
23 | 24 | import io.branch.indexing.*; |
@@ -79,6 +80,7 @@ public class RNBranchModule extends ReactContextBaseJavaModule { |
79 | 80 |
|
80 | 81 | private static Activity mActivity = null; |
81 | 82 | private static boolean mUseDebug = false; |
| 83 | + private static boolean mInitialized = false; |
82 | 84 |
|
83 | 85 | private AgingHash<String, BranchUniversalObject> mUniversalObjectMap = new AgingHash<>(AGING_HASH_TTL); |
84 | 86 |
|
@@ -592,21 +594,17 @@ public static LinkProperties createLinkProperties(ReadableMap linkPropertiesMap, |
592 | 594 | } |
593 | 595 |
|
594 | 596 | private static Branch setupBranch(Context context) { |
595 | | - RNBranchConfig config = new RNBranchConfig(context); |
596 | | - String branchKey = config.getBranchKey(); |
597 | | - if (branchKey == null) branchKey = config.getUseTestInstance() ? config.getTestKey() : config.getLiveKey(); |
598 | | - |
599 | | - /* |
600 | | - * This differs a little from iOS. If you add "useTestInstance": true to branch.json but |
601 | | - * don't add the testKey, on iOS, it will use the test key from the Info.plist if configured. |
602 | | - * On Android, useTestInstance in branch.json will be ignored unless testKey is present. If |
603 | | - * testKey is not specified in branch.json, it's necessary to add io.branch.sdk.TestMode to |
604 | | - * the Android manifest to use the test instance. It's not clear if there's a programmatic |
605 | | - * way to select the test key without specifying the key explicitly. |
606 | | - */ |
607 | | - Branch branch = branchKey != null ? Branch.getInstance(context, branchKey) : Branch.getInstance(context); |
608 | | - |
609 | | - if (mUseDebug || config.getDebugMode()) branch.setDebug(); |
| 597 | + Branch branch = Branch.getInstance(context); |
| 598 | + |
| 599 | + if (!mInitialized) { |
| 600 | + Log.i(REACT_CLASS, "Initializing Branch SDK v. " + BuildConfig.VERSION_NAME); |
| 601 | + |
| 602 | + RNBranchConfig config = new RNBranchConfig(context); |
| 603 | + |
| 604 | + if (mUseDebug || config.getDebugMode()) branch.setDebug(); |
| 605 | + |
| 606 | + mInitialized = true; |
| 607 | + } |
610 | 608 |
|
611 | 609 | return branch; |
612 | 610 | } |
|
0 commit comments