我希望能够在点击动态链接时打开应用程序并打印参数(即使它未发布)。
有没有方法可以做到这一点?
我希望能够在点击动态链接时打开应用程序并打印参数(即使它未发布)。
有没有方法可以做到这一点?
是的!实际上,在入门视频(part 1)、(part 2)中,我会经历这个确切的过程。如果你还没有看过这些视频,我建议你去看一下。
但是,总体来说,您可以通过点击动态链接来测试“如果已安装我的应用程序,则打开我的应用程序”流程。如果您的应用程序已安装在设备上,它应该可以正常打开;即使它不是一个发布的应用程序。
如果您想测试未安装的流程,这也很容易。
application: UIApplication, continue userActivity: NSUserActivity, restorationHandler
方法,但当应用程序未被安装时,会调用app: UIApplication, open url: URL, options
方法。@Todd Kerpelman 这样正确吗? - Tom Spee我曾经遇到过同样的问题,花费了很多时间寻找解决办法,并按照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.
*/