Detox does not handle universal links

自作多情 提交于 2019-12-11 15:35:06

问题


I've been trying to get iOS Universal Links to work with Detox using device.openURL from https://github.com/wix/Detox/blob/master/docs/APIRef.MockingOpenFromURL.md but it does not work.

Sample of what I've tried:

it('should work', async () => {
  await device.sendToHome();
  await device.openURL({
    url: 'https://name.page.link/somewhere,
    sourceApp: 'com.apple.MobileSMS'
  });
});

It never opens my app and after testing various things it seems detox only support deep links and not universal links.

I can mention that when running the app (both on device and simulator) the universal links work fine which leads me to believe the issue is not with how I have configured universal links but with detox support for it.

In iOS UI Testing it is doable to test universal links by going through iMessage app (see https://blog.branch.io/ui-testing-universal-links-in-xcode-9/). Anyone know of a similar workaround for detox?


回答1:


You used this code in AppDelegate.m:

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

But it is not supported by Detox. You should use:

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


来源:https://stackoverflow.com/questions/53576538/detox-does-not-handle-universal-links

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!