branch.io deep-linked URL not passing data in App from Facebook Ads

亡梦爱人 提交于 2019-12-04 15:19:55

Unfortunately the branch.io documentation for setting this is up is pretty incomplete - we just spent about a week testing and debugging the SDK to figure out how to get it to work. The necessary changes itself are actually quite simple.

On Android:

  1. Integrate the Facebook SDK if you haven't done so already
  2. Ensure that the facebook_app_id string resource you added as part of (1) is not prefixed with "fb"
  3. If you are using ProGuard, add rules to keep the relevant parts of the Facebook SDK
  4. Call enableFacebookAppLinkCheck() on your Branch instance right after initializing it

On iOS:

  1. Integrate the Facebook SDK if you haven't done so already
  2. Call registerFacebookDeepLinkingClass(FBSDKAppLinkUtility.self) on your Branch instance right after initializing it

I had this exact same problem, but in a React Native project, so I'm using react-native-branch. @henning-dodenhof 's answer helped me a lot (thanks for figuring this out!), but I needed a couple of further adaptations, so I add this answer in case it's useful for someone else since this post was the main thing I found regarding this issue:

For iOS: The FB SDK registration needs to happen before initializing Branch, not after as the above answer suggests. So, before this line that you add as part of the normal library setup:

[RNBranch initSessionWithLaunchOptions:launchOptions isReferrable:YES];

You need get the Branch instance from RNBranch and then register this FB SDK class:

[[RNBranch branch] registerFacebookDeepLinkingClass:[FBSDKAppLinkUtility class]];

Adding this new line before the initialization is critical, doesn't work if it's done after.

For Android: Here the setup code already gets an instance with Branch.getAutoInstance(this), so we can just chain the registration:

Branch.getAutoInstance(this).enableFacebookAppLinkCheck();

It looks like the getAutoInstance above doesn't actually fully initializes the instance, so you can call enableFacebookAppLinkCheck right after, and the instance gets fully initialized after the first use.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!