[英]Firebase dynamic link short url returns nil ios
我遇到了 Firebase 动态链接的问题。 链接是从后端生成的。 它在 android 中完美运行。 但是在 iOS 中,当我在 iPhone 上的 whatsapp 或消息应用程序上共享动态链接时。 并点击链接应用程序打开。 而我们下面的 function 在 Appdelegate 中被调用。 然后用收到的 URL 调用 firebase function。 firebase 函数返回 nil。 But when I open that link from the safari app is opened and that same firebase function returns the deeplink URL. 我已经搜索了很多但没有找到解决方案。 我正在使用 firebase 7.11 版本的吊舱。
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
if let incomingUrl = userActivity.webpageURL{
print("Incoming URL is \(incomingUrl)")
let linkHandled = DynamicLinks.dynamicLinks().handleUniversalLink(incomingUrl) { (dynamicLink, error) in
// guard error == nil else{
// print("Found an error! \(error!.localizedDescription)")
// return
// }
print("error \(error)")
print("dynamicLink \(dynamicLink)") // It returns nil when app open from whatsapp or any 3rd party app.
}
if linkHandled{
return true
}else{
return false
}
}
return false
}
在这两种情况下,我也收到以下错误。
Error Domain=com.firebase.dynamicLinks Code=403 "(null)" UserInfo={code=403, message=Requests to this API firebasedynamiclinks.googleapis.com method google.firebase.dynamiclinks.v1.DynamicLinksService.GetIosReopenAttribution are blocked., status=PERMISSION_DENIED, details=(
{
"@type" = "type.googleapis.com/google.rpc.ErrorInfo";
domain = "googleapis.com";
metadata = {
consumer = "projects/37866531840";
service = "firebasedynamiclinks.googleapis.com";
};
reason = "API_KEY_SERVICE_BLOCKED";
}
)}
您是否在 function didFinishLaunchingWithOptions 下的 AppDelegate class 中将 AppBundle id 设置为 deepLinkURLScheme,如下所示
let kAppBundleID = Bundle.main.bundleIdentifier
FirebaseOptions.defaultOptions()?.deepLinkURLScheme = kAppBundleID
请试试这个。
参考: https://firebase.google.com/docs/dynamic-links/ios/create
默认情况下,动态链接使用您的应用程序包标识符作为打开您的应用程序所需的 URL 方案。 我们建议保留此默认值以使您的实现简单。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.