skip to Main Content

In react native the iOS Universal links are working perfectly when the app is in kill/quiet state I tested it with safari but when the app is in background state it only opens the app not working in background state my listener is not working.

Linking.addEventListener('url', async (link) => {
    console.log('Linking-addEventListener-link', link);
})

2

Answers


  1. Please check this method is added or not into AppDelegate.m file.

    - (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity
     restorationHandler:(nonnull void (^) (NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler
    {
         return [RCTLinkingManager application:application
              continueUserActivity:userActivity
             restorationHandler:restorationHandler];
     }
    
    Login or Signup to reply.
  2. For everyone having the same issue, just make sure that
    #import <React/RCTLinkingManager.h> is just at the top of the imports, do not add it inside any #if #endif import condition.

    also add

     - (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];
    }
    
        
    

    just before the last @end inside the @implementation AppDelegate, hope it might help someone.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search