-
Notifications
You must be signed in to change notification settings - Fork 104
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
Branch config plugin doesn't do deferred deep link checkPasteboardOnInstall #251
Comments
Running into the same issue. |
@jvgeee After prebuild, I manually updated the development pod like so, ran the project, and got the desired outcome: Do you know how we can make this "backward compatible" by only running that line based on some config property? Then we can make a PR with the fix |
@jvgeee I used patch-package to apply that diff for now. Ran an eas build and all works perfectly now. Would be nice for someone more experienced with updating this package to put up a proper PR with it. |
@IkeyBenz I've done this too, although it's not successfully getting it to work after a build. On my end, I've added Which development pod (and which file) are you editing in Xcode? And can you share your patch-package file? I'm obviously doing something wrong so want to get it right! |
@IkeyBenz Also, are you getting a prompt on install saying Update: It seems like Branch only runs the pasteboard check on (a) first install, and (b) when there's a branch URI copied to my phone's clipboard. The missing piece for me seems to be that on my deep link's custom webpage, I need to be copying the branch URI to the phone's clipboard. The next issue is that I have no way to read the URI on the clipboard, Branch isn't properly "receiving" it and it's not in firstReferringParams or latestReferringParams... |
I just spoke to Branch support (they're terrible) and after over a month they told me that you're meant to enable it by adding a I had to google around and found this: https://github.com/BranchMetrics/react-native-branch-deep-linking-attribution/blob/master/docs/branch.json.md Don't know how to get a branch.json file linked in with the Branch SDK via an expo config plugin though |
Here's my patch file: some notable differences:
Yes, this is what I needed for my use case. You're right it's probably not working if it's not showing you that prompt. You need to enable native link in Branch's configuration tab https://dashboard.branch.io/configuration/general
So I have this fun code snippet from two years ago when Apple started asking people if they want to allow pasting from clipboard, before enabling Branch to read from it. That prompt was async causing my on-first-install attribution logic to mistakenly call Branch.getFirstReferringParams before it had access to the clipboard. Here is the snippet I used to make it wait for clipboard permissions prior to calling Branch.getFirstRefferingParams: /**
* This is a hack to delay our attribution handler by the amount of time it
* takes the user to press "yes" on the iOS 16 prompt to enable clipboard pasting
* in our app. Otherwise attribution info doesn't get recorded until subsequent app open.
*/
const waitForiOS16Paste = () => {
return isFirstAppInstall().then((isFirstInstall) => {
const timeout = () => new Promise((res) => setTimeout(res, 2000));
if (isFirstInstall) {
if (Platform.OS !== 'ios') {
return timeout();
}
// on iOS, we want to wait until we have ability to read from their clipboard
// before proceeding
return Clipboard.hasString()
.then((hasString: boolean) => {
if (hasString) return Clipboard.getString();
})
.catch(() => {})
.finally(() => timeout());
}
});
};
const isFirstAppInstall = () => {
const key = 'IS_FIRST_APP_INSTALL' as const;
return settings
.get<boolean>(key)
.then((val) => {
if (val === null) {
return settings.set(key, false).then(() => {
return true; // must be first app install if this was never set
});
}
return false;
})
.catch(() => false);
}; Notes:
|
Summary
To use deferred deep linking for Branch, you need to use IOS Branch's checkPasteboardOnInstall() method:
IOS SDK instructions: https://help.branch.io/developers-hub/docs/ios-advanced-features#nativelink-deferred-deep-linking
RN Instructions: https://help.branch.io/developers-hub/docs/react-native-advanced-features#nativelink-deferred-deep-linking
I've tried patching these methods into the config plugin but I can't get it to work, would appreciate some help here.
Config Plugin
@config-plugins/react-native-branch
What platform(s) does this occur on?
iOS
SDK Version
No response
Reproducible demo
NA, it's just missing from the list of available methods in the config swift file.
You can see in the Branch docs that for deferred deep linking to work on IOS (using their "nativelink" product), you need to call
Branch.checkPasteboardOnInstall()
in the IOS setup. This is not happening in the config plugin and not available as part of the SDK, so needs to be enabled to allow for all of Branch's functionality.The text was updated successfully, but these errors were encountered: