我阅读了所有可用的文档并尝试了Firebase示例代码,但似乎没有任何效果。
我已经通过控制台设置了动态链接,它运行正常。
有人可以解释我如何创建最基本的动态链接,以便用户可以例如可以发送直接导致他的个人资料的链接?哪些是最低要求?
(如果有人可以在Objective-C中发布基本代码,会很棒)
答案 0 :(得分:1)
此页面是否可以帮助您https://firebase.google.com/docs/dynamic-links/ios/create? 您可以在https://github.com/firebase/quickstart-ios/tree/master/dynamiclinks
找到示例代码答案 1 :(得分:1)
我假设您要发送一些键值对,也就是URL的正文中的字典
以下是如何撰写Convert dictionary to query string in swift?
所以第一步是创建该URL
接下来,您可以手动撰写firebase动态链接https://firebase.google.com/docs/dynamic-links/create-manually
您还可以在https://firebase.googleblog.com/2017/06/making-dynamic-links-easier.html
@IBAction func createGroupAction(_ sender: Any) {
let dynamicLinkDomain = "a5481.app.goo.gl" // <- don't add https scheme to this string
let appBundleID = "com.vividapartments.myStr.com"
let params:[String : String] = [
"ibi": appBundleID,
"isi": "1222420082",
"efr":"1",
"groupID":"-LDSfWKKbWjyrXiFljT3",
"chatID":"-LDSfWKMbm9mSE2a6EIe"
]
// general link params
let urlParams = params.flatMap ({ (key,value) -> String in
return "\(key)=\(value)"
}).joined(separator: "&")
guard let deepLink = URL(string:"https://www.mystr.com/groups?\(urlParams)") else {return}
print("deepLink is \(deepLink)")
//prints:
//deepLink is https://www.mystr.com/groups?isi=1222420082&chatID=-LDSfWKMbm9mSE2a6EIe&efr=1&ibi=com.vividapartments.myStr.com&groupID=-LDSfWKKbWjyrXiFljT3
let components = DynamicLinkComponents(link: deepLink, domain: dynamicLinkDomain)
let iOSParams = DynamicLinkIOSParameters(bundleID: appBundleID)
iOSParams.minimumAppVersion = "1.5"
components.iOSParameters = iOSParams
//1. Build the dynamic long link
let longlLink = components.url
print("The long link is \(longlLink!)")
//prints:
//The long link is https://a5481.app.goo.gl/?link=https%3A%2F%2Fwww%2Emystr%2Ecom%2Fgroups%3Fisi%3D1222420082%26chatID%3D%2DLDSfWKMbm9mSE2a6EIe%26efr%3D1%26ibi%3Dcom%2Evividapartments%2EmyStr%2Ecom%26groupID%3D%2DLDSfWKKbWjyrXiFljT3&ibi=com%2Evividapartments%2EmyStr%2Ecom&imv=1%2E5
//Set the length of a short Dynamic Link
let options = DynamicLinkComponentsOptions()
options.pathLength = .unguessable
components.options = options
//2. Or create a shortened dynamic link
components.shorten { (shortURL, warnings, error) in
if let error = error {
print("error is \(error.localizedDescription)")
return
}
// TODO: Handle shortURL.
print("shortURL is \(String(describing: shortURL))")
}
}