facebookarchive / react-native-fbsdk

A React Native wrapper around the Facebook SDKs for Android and iOS. Provides access to Facebook login, sharing, graph requests, app events etc.
https://developers.facebook.com/docs/react-native
Other
2.99k stars 908 forks source link

My app not getting FB deep link when installed through App Store #428

Open ilyakar opened 5 years ago

ilyakar commented 5 years ago

Hi guys,

My FB Deferred deep link is: einee://free_marilyn_monroe=true. Clicking on Install in the test ad (when the app is already installed) works fine. However, when the app is not yet installed and clicking on the FB ad Install button which takes the user to the App Store, the deep link is not found when the app launches.

This is my code in React Native to detect the deep link:

Linking.getInitialURL().then((url) => {
    if(url){
        if(url.includes('free_marilyn_monroe=true')){
            // Deep link detected code
    }
    }
    // ...

This is my AppDelegate.m file code:

/**
 * Copyright (c) 2015-present, Facebook, Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

#import "AppDelegate.h"

#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import "SplashScreen.h"
#import <Fabric/Fabric.h>
#import <Crashlytics/Crashlytics.h>
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <react-native-branch/RNBranch.h>

@import GoogleMobileAds;
@import Firebase;

@implementation AppDelegate

- (void)applicationDidBecomeActive:(UIApplication *)application {
  [FBSDKAppEvents activateApp];
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  [FIRApp configure];

  // Uncomment this line to use the test key instead of the live one.
  // [RNBranch useTestInstance];
  [RNBranch initSessionWithLaunchOptions:launchOptions isReferrable:YES];
  NSURL *jsCodeLocation;

  jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];

  RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                      moduleName:@"Einee"
                                               initialProperties:nil
                                                   launchOptions:launchOptions];
  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];

  [[FBSDKApplicationDelegate sharedInstance] application:application
                           didFinishLaunchingWithOptions:launchOptions];

  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];
  [SplashScreen show];
  [Fabric with:@[[Crashlytics class]]];
  [GADMobileAds configureWithApplicationID:@"ca-app-pub-3594094751431969~9145980369"];
  return YES;
}

// Respond to URI scheme links
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
  if (![RNBranch.branch application:application openURL:url options:options]) {
    // Facebook scheme click detect
    return [[FBSDKApplicationDelegate sharedInstance] application:application openURL:url sourceApplication:sourceApplication annotation:annotation];
  }
  return YES;
}

- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray *restorableObjects))restorationHandler {
  return [RNBranch continueUserActivity:userActivity];
}

@end

Am I detecting the deep link wrong? Please help!

namanyayg commented 5 years ago

Did you find any solution yet? Looking to implement deep links on Android.

ZeerakHameem32 commented 5 years ago

Any solution for this?

acro5piano commented 5 years ago

I think we have to write bridge module cause react-native-fbsdk seems not to support deferred deep link.

https://developers.facebook.com/docs/app-ads/deep-linking/

I'll try to implement it and share them here if I found something useful.

afestein commented 5 years ago

I also have this issue, even though Facebook's "App Ads Helper" shows that everything is set up correctly (see screenshot):

image

@acro5piano did you have any luck looking into it?

acro5piano commented 5 years ago

@afestein Sorry not yet.

hamzahayat commented 4 years ago

@acro5piano Any update or luck looking into deferred deep linking for react-native?

acro5piano commented 4 years ago

I ended up with installing AppsFlyer SDK natively.