Skip to content

[ios] Linking doesn't work with ios12 due to new continue userActivity implementation  #22716

Closed
@xzilja

Description

@xzilja

Environment

  React Native Environment Info:
    System:
      OS: macOS 10.14.1
      CPU: x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
      Memory: 293.77 MB / 16.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 10.14.2 - /usr/local/bin/node
      Yarn: 1.12.3 - /usr/local/bin/yarn
      npm: 6.4.1 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
    IDEs:
      Android Studio: 3.2 AI-181.5540.7.32.5056338
      Xcode: 10.1/10B61 - /usr/bin/xcodebuild
    npmPackages:
      @types/react: 16.7.17 => 16.7.17 
      @types/react-native: 0.57.18 => 0.57.18 
      react: 16.7.0-alpha.2 => 16.7.0-alpha.2 
      react-native: 0.57.8 => 0.57.8 
    npmGlobalPackages:
      react-native-cli: 2.0.1

Description

Per linking documentation iOS implementation for handling universal links right now is

- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity
 restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler
{

 // Debug log something here
 return [RCTLinkingManager application:application
                  continueUserActivity:userActivity
                    restorationHandler:restorationHandler];
}

With iOS 12 and XCode 10 this no longer seems to work (I think ios 12 forces new implementation?), there is new way to handle universal links that should look like this

- (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity 
restorationHandler: (nonnull void (^)(NSArray<id<UIUserActivityRestoring>> *_Nullable))restorationHandler {

  // Debug log something here
  return [RCTLinkingManager application:application
                  continueUserActivity:userActivity
                    restorationHandler:restorationHandler];
}

As you can see they added UIUserActivityRestoring as a new type for restorationHandler. When running on iOS 12 and using old approach I don't see my // Debug log something here message at all. When I use new approach I see the message, but app crashes at RCTLinkingManager with following error

Thread 1: EXC_BREAKPOINT (code=1, subcode=0x100a9cde0)

There is also an xcode issue saying

Cannot convert value of type '([UIUserActivityRestoring]?) -> Void' to expected argument type '(([Any]?) -> Void)?'

Related apple docs entry: https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1623072-application?language=objc

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions