Search code examples
iosswiftreact-nativeios-universal-links

Universal Deep Linking in react native 0.73


I have recently upgraded my React Native project from version 0.70 to 0.73. In the previous version (0.70), my universal linking functionality was functioning properly. However, with the upgrade to version 0.73, I noticed a significant change. The project now includes an AppDelegate.mm file instead of the previous AppDelegate.m file. Despite this change, the documentation still provides handler functions for the older AppDelegate.m file.

- (BOOL)application:(UIApplication *)application
   openURL:(NSURL *)url
   options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
  return [RCTLinkingManager application:application openURL:url options:options];
}

- (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity
 restorationHandler:(nonnull void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler
{
 return [RCTLinkingManager application:application
                  continueUserActivity:userActivity
                    restorationHandler:restorationHandler];
} 

I am seeking assistance with converting these handlers. The goal is to paste them into my AppDelegate.mm file, enabling my universal linking to function properly.


Solution

  • Although documentation said to past those handlers AppDelegate.m file, the same handlers when pasted in AppDelegate.mm worked for me.

    AppDelegate.mm

    - (BOOL)application:(UIApplication *)application
       openURL:(NSURL *)url
       options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
    {
      return [RCTLinkingManager application:application openURL:url options:options];
    }
    
    - (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity
     restorationHandler:(nonnull void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler
    {
     return [RCTLinkingManager application:application
                      continueUserActivity:userActivity
                        restorationHandler:restorationHandler];
    }