-
Notifications
You must be signed in to change notification settings - Fork 208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SDK-2326] Add setAPIUrl to the JS layer #967
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import { NativeModules, Platform } from "react-native"; | ||
|
||
const { RNBranch } = NativeModules; | ||
|
||
import createBranchUniversalObject from "./branchUniversalObject"; | ||
import BranchEvent from "./BranchEvent"; | ||
import BranchSubscriber from "./BranchSubscriber"; | ||
|
||
const packageFile = require("./../package.json"); | ||
export const VERSION = packageFile.version; | ||
|
||
class Branch { | ||
|
@@ -17,11 +17,11 @@ | |
constructor(options = {}) { | ||
if (options.debug) this._debug = true; | ||
|
||
console.info("Initializing react-native-branch v. " + VERSION); | ||
} | ||
|
||
subscribe(options) { | ||
if (typeof options === "function") { | ||
/* | ||
* Support for legacy API, passing a single callback function: | ||
* branch.subscribe(({params, error, uri}) => { ... }). This is | ||
|
@@ -36,7 +36,7 @@ | |
* You can specify checkCachedEvents in the subscribe options to control | ||
* this per subscriber. | ||
*/ | ||
if (!("checkCachedEvents" in options)) { | ||
options.checkCachedEvents = this._checkCachedEvents; | ||
} | ||
this._checkCachedEvents = false; | ||
|
@@ -66,13 +66,13 @@ | |
setIdentityAsync = (identity) => RNBranch.setIdentityAsync(identity); | ||
setRequestMetadata = (key, value) => { | ||
console.info( | ||
"[Branch] setRequestMetadata has limitations when called from JS. Some network calls are made prior to the JS layer being available, those calls will not have the metadata." | ||
); | ||
return RNBranch.setRequestMetadataKey(key, value); | ||
}; | ||
addFacebookPartnerParameter = (name, value) => { | ||
console.info( | ||
"[Branch] addFacebookPartnerParameter has limitations when called from JS. Some network calls are made prior to the JS layer being available, those calls will not have the partner parameters." | ||
); | ||
return RNBranch.addFacebookPartnerParameter(name, value); | ||
}; | ||
|
@@ -164,6 +164,17 @@ | |
console.warn("setDMAParamsForEEA: Unable to set DMA params."); | ||
} | ||
}; | ||
|
||
/*** Set the Branch API's base URL (eg. "https://api2.branch.io") ***/ | ||
setAPIUrl = (apiUrl) => { | ||
if (!apiUrl || typeof apiUrl !== "string" || !apiUrl.startsWith("http")) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
console.warn( | ||
"setAPIUrl: Invalid URL. URL must be a non-empty string starting with 'http'." | ||
); | ||
return; | ||
} | ||
RNBranch.setAPIUrl(apiUrl); | ||
}; | ||
} | ||
|
||
const validateParam = (param, paramName) => { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend removing the JavaScript API and moving this to the native JSON api. The JS <> native runtime switch will be a race condition against this setting which must be called before session init.
Instead, the json can be read on the native init's start up.