如果我的应用程序不在应用商店中,我如何测试Firebase动态链接?

50

我希望能够在点击动态链接时打开应用程序并打印参数(即使它未发布)。

有没有方法可以做到这一点?


你看过这个答案吗?或许可以尝试实现相同的方法,只需在需要的地方添加一些日志输出即可。 - AL.
2个回答

103

是的!实际上,在入门视频(part 1)(part 2)中,我会经历这个确切的过程。如果你还没有看过这些视频,我建议你去看一下。

但是,总体来说,您可以通过点击动态链接来测试“如果已安装我的应用程序,则打开我的应用程序”流程。如果您的应用程序已安装在设备上,它应该可以正常打开;即使它不是一个发布的应用程序。

如果您想测试未安装的流程,这也很容易。

  • 首先,在项目设置中为Firebase项目添加应用商店ID。它可以是任何有效的应用商店ID-它不必是您的应用程序的ID。
  • 然后生成一个新的动态链接。
  • 这次,当您点击此新链接时,它应该将您带到上面列出的应用商店。您不需要实际安装此应用-只需到达应用商店列表即可。
  • 现在,重新安装和运行您的应用程序。如果一切正常,它应该会检索并显示动态链接数据。

7
非常感谢 - 它如预期般有效。小细节:为了进行快速测试,您甚至不需要应用商店ID - 只需点击动态链接,它会跳转到Play商店并显示“未找到项目”。接下来,只需安装您的应用程序 - 它将自动从意图中接收链接,并像按下链接一样运行。 - Apporve Chandra
4
这是测试未安装流的好方法。我发现当应用程序被安装后,会调用application: UIApplication, continue userActivity: NSUserActivity, restorationHandler方法,但当应用程序未被安装时,会调用app: UIApplication, open url: URL, options方法。@Todd Kerpelman 这样正确吗? - Tom Spee
完美的答案! - Vishwas Singh
我尝试了这个,但是我只得到了“CapacitorFirebaseDynamicLinks.handleLink() - 动态链接没有URL”的错误信息。 - MadMac
1
啊!只有启用预览页面才能正常工作。https://github.com/firebase/firebase-ios-sdk/issues/1244#issuecomment-502469160 - MadMac
显示剩余6条评论

2

我曾经遇到过同样的问题,花费了很多时间寻找解决办法,并按照Todd Kerpelman在帖子中所解释的调试说明进行操作后,我发现Firebase在第一次启动应用程序时没有发送通用链接,而是发送了以下结构的方案URL:

[bundle_id]://google/link/?deep_link_id=[firebase_universal_link]

在确定了这一点之后,我在Firesabe SDK中找到了dynamicLinkFromCustomSchemeURL方法,并通过动态链接解决了我的问题,使应用程序在第一次启动时顺利运行。

/**
 * @method dynamicLinkFromCustomSchemeURL:
 * @abstract Get a Dynamic Link from a custom scheme URL. This method parses URLs with a custom
 *     scheme, for instance, "comgoogleapp://google/link?deep_link_id=abc123". It is suggested to
 *     call it inside your |UIApplicationDelegate|'s
 *     |application:openURL:sourceApplication:annotation| and |application:openURL:options:|
 *     methods.
 * @param url Custom scheme URL.
 * @return Dynamic Link object if the URL is valid and has link parameter, otherwise nil.
 */
- (nullable FIRDynamicLink *)dynamicLinkFromCustomSchemeURL:(NSURL *)url
    NS_SWIFT_NAME(dynamicLink(fromCustomSchemeURL:));

/**
 * @method dynamicLinkFromUniversalLinkURL:completion:
 * @abstract Get a Dynamic Link from a universal link URL. This method parses the universal link
 *     URLs, for instance,
 *     "https://example.page.link?link=https://www.google.com&ibi=com.google.app&ius=comgoogleapp".
 *     It is suggested to call it inside your |UIApplicationDelegate|'s
 *     |application:continueUserActivity:restorationHandler:| method.
 * @param URL Custom scheme URL.
 * @param completion A block that handles the outcome of attempting to get a Dynamic Link from a
 * universal link URL.
 */
- (void)dynamicLinkFromUniversalLinkURL:(NSURL *)url
                             completion:(FIRDynamicLinkUniversalLinkHandler)completion
    NS_SWIFT_NAME(dynamicLink(fromUniversalLink:completion:));

/**
 * @method dynamicLinkFromUniversalLinkURL:
 * @abstract Get a Dynamic Link from a universal link URL. This method parses universal link
 *     URLs, for instance,
 *     "https://example.page.link?link=https://www.google.com&ibi=com.google.app&ius=comgoogleapp".
 *     It is suggested to call it inside your |UIApplicationDelegate|'s
 *     |application:continueUserActivity:restorationHandler:| method.
 * @param url Custom scheme URL.
 * @return Dynamic Link object if the URL is valid and has link parameter, otherwise nil.
 */

嗨,我遇到了同样的问题... 你能详细说明一下dynamicLinkFromCustomSchemeURL吗?或者给我发送代码。 - Muhammad Ahmad

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接