React-native: React native linking with react native fbsdk

Created on 11 Mar 2017  路  2Comments  路  Source: facebook/react-native

After debugging, I found out why my app isn't receving the deep links.

It's because of the fb code:

- (BOOL)application:(UIApplication *)application
        openURL:(NSURL *)url
        options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {

BOOL handled = [[FBSDKApplicationDelegate sharedInstance] application:application
                                                            openURL:url
                                                  sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]
                                                         annotation:options[UIApplicationOpenURLOptionsAnnotationKey]
              ];
// Add any custom logic here.
return handled;
}

How do you suppose to combine these for the rn-linking code, since this is also required:

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
  return [RCTLinkingManager application:application openURL:url
                      sourceApplication:sourceApplication annotation:annotation];
}
Locked

Most helpful comment

Including linking, RN fbsdk, and RN google-signin:

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {

  return [[FBSDKApplicationDelegate sharedInstance] application:application
                                                        openURL:url
                                              sourceApplication:sourceApplication
                                                     annotation:annotation
          ]
  || [RNGoogleSignin application:application
                         openURL:url
               sourceApplication:sourceApplication
                      annotation:annotation
      ]
  || [RCTLinkingManager application:application openURL:url
                  sourceApplication:sourceApplication annotation:annotation
      ];

}

All 2 comments

What I did was used a if statement as follows:

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {

  NSString * scheme = (NSString*)url.scheme;
  NSString * fbScheme = @"fb123456789";

  if ([fbScheme isEqualToString:scheme]) {
    return [[FBSDKApplicationDelegate sharedInstance]
            application:application openURL:url sourceApplication:sourceApplication annotation:annotation];
  } else {
    //Your other stuff here
  }
}

Including linking, RN fbsdk, and RN google-signin:

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {

  return [[FBSDKApplicationDelegate sharedInstance] application:application
                                                        openURL:url
                                              sourceApplication:sourceApplication
                                                     annotation:annotation
          ]
  || [RNGoogleSignin application:application
                         openURL:url
               sourceApplication:sourceApplication
                      annotation:annotation
      ]
  || [RCTLinkingManager application:application openURL:url
                  sourceApplication:sourceApplication annotation:annotation
      ];

}
Was this page helpful?
0 / 5 - 0 ratings