iOS - 如何获取 AppsFlyer One-Link 中的参数。应用已安装并启动
iOS - How to get params in One-Link of AppsFlyer. App was installed and launched
如果我的应用程序未安装,我可以获得 One-Link 的参数(活动、媒体源等...)。我使用下面的方法来做到这一点。
func onConversionDataReceived(_ installData: [AnyHashable : Any]!) {
if let data = installData{
print("\(data)")
if let status = data["af_status"] as? String{
if(status == "Non-organic"){
if let sourceID = data["media_source"] , let campaign = data["campaign"]{
print("This is a Non-Organic install. Media source: \(sourceID) Campaign: \(campaign)")
}
} else {
print("This is an organic install.")
}
}
}
}
但是,如果我的应用程序已安装、启动,然后我点击另一个 One-Link 打开我的应用程序,我只能通过以下方法得到这个 URL:
func onAppOpenAttribution(_ attributionData: [AnyHashable : Any]!) {
if let data = attributionData{
print("\(data)")
}
}
如果我的应用程序在设备上可用,那么有什么方法可以获取参数(活动、媒体源等...)?
注意:我使用了短 link。
onAppOpenAttribution
每次您从不同深度打开应用程序时都会触发-link(在您的情况下是 One-Link)。
I can get params (campaign, media-source, etc...) of One-Link if my app does not install.
对,第一次触发两个回调onAppOpenAttribution
和onConversionDataReceived
。
But if my app was installed, launched and then I click on another One-Link to open my app
如果您尝试从 One-Link 打开不属于 Appsflyer 的应用程序,就会发生这种情况。
例如,此 link(通用 Link)https://rndemotest.onelink.me/7y5s/f78c46d5
将通过 onAppOpenAttribution
为您提供媒体来源、活动等,其中 7y5s
是您在仪表板 "ONELINK CONFIGURATION" 部分中定义的 One-Link ID。
[编辑]
确保你 运行 最新的 AppsFlyer SDK 版本,
Deep linking with short links for iOS Universal Links or Android App Links is only supported from SDK version 4.8.0
通常,对于 Full link a.e,您应该得到 {"link": "<URL>"}
的响应。 {"link":"https://abc.onelink.me/2347196006?pid=User%20invite&c=CMTT2019einvite&af_dp=abc%3A%2F%2F"}
对于 One-Link,您应该获取包含媒体源的所有信息,...。
顺便说一句,这是一个代码片段示例,说明如何处理 onAppOpenAttribution
响应:
func onAppOpenAttribution(_ attributionData: [AnyHashable : Any]!) {
var attDataString:String = ""
var params = [String: String]()
print("")
print("<-------------------------------------------------->")
print("onAppOpenAttribution is:")
if let pid = attributionData[AnyHashable("pid")] as? String{
attDataString.append("PID: " + pid + "\n\n")
print(helper(module: "pid", message: pid))
}
if let is_retargeting = attributionData[AnyHashable("is_retargeting")] as? String{
attDataString.append("is_retargeting: " + is_retargeting + "\n\n")
print(helper(module: "is_retargeting", message: is_retargeting))
}
if let campaign = attributionData[AnyHashable("c")] as? String{
attDataString.append("Campaign: " + campaign + "\n\n")
print(helper(module: "campaign", message: campaign))
}
if let link = attributionData[AnyHashable("link")] as? String{
attDataString.append("Link: " + link + "\n\n")
print(helper(module: "link", message: link))
}
if let af_dp = attributionData[AnyHashable("af_dp")] as? String{
attDataString.append("af_dp: " + af_dp + "\n\n")
print(helper(module: "af_dp", message: af_dp))
}
print(attributionData)
print("<-------------------------------------------------->")
print("")
// dump(attributionData)
}
func helper(module:String!, message:String!) -> String!{
var sb:String = ""
sb.append(" " + module + "=")
var pad:Int = 17 - module.characters.count
while pad > 0 {
pad-=1
sb.append( " " )
}
sb.append(" " + message)
return sb
}
如果我的应用程序未安装,我可以获得 One-Link 的参数(活动、媒体源等...)。我使用下面的方法来做到这一点。
func onConversionDataReceived(_ installData: [AnyHashable : Any]!) {
if let data = installData{
print("\(data)")
if let status = data["af_status"] as? String{
if(status == "Non-organic"){
if let sourceID = data["media_source"] , let campaign = data["campaign"]{
print("This is a Non-Organic install. Media source: \(sourceID) Campaign: \(campaign)")
}
} else {
print("This is an organic install.")
}
}
}
}
但是,如果我的应用程序已安装、启动,然后我点击另一个 One-Link 打开我的应用程序,我只能通过以下方法得到这个 URL:
func onAppOpenAttribution(_ attributionData: [AnyHashable : Any]!) {
if let data = attributionData{
print("\(data)")
}
}
如果我的应用程序在设备上可用,那么有什么方法可以获取参数(活动、媒体源等...)?
注意:我使用了短 link。
onAppOpenAttribution
每次您从不同深度打开应用程序时都会触发-link(在您的情况下是 One-Link)。
I can get params (campaign, media-source, etc...) of One-Link if my app does not install.
对,第一次触发两个回调onAppOpenAttribution
和onConversionDataReceived
。
But if my app was installed, launched and then I click on another One-Link to open my app
如果您尝试从 One-Link 打开不属于 Appsflyer 的应用程序,就会发生这种情况。
例如,此 link(通用 Link)https://rndemotest.onelink.me/7y5s/f78c46d5
将通过 onAppOpenAttribution
为您提供媒体来源、活动等,其中 7y5s
是您在仪表板 "ONELINK CONFIGURATION" 部分中定义的 One-Link ID。
[编辑]
确保你 运行 最新的 AppsFlyer SDK 版本,
Deep linking with short links for iOS Universal Links or Android App Links is only supported from SDK version 4.8.0
通常,对于 Full link a.e,您应该得到 {"link": "<URL>"}
的响应。 {"link":"https://abc.onelink.me/2347196006?pid=User%20invite&c=CMTT2019einvite&af_dp=abc%3A%2F%2F"}
对于 One-Link,您应该获取包含媒体源的所有信息,...。
顺便说一句,这是一个代码片段示例,说明如何处理 onAppOpenAttribution
响应:
func onAppOpenAttribution(_ attributionData: [AnyHashable : Any]!) {
var attDataString:String = ""
var params = [String: String]()
print("")
print("<-------------------------------------------------->")
print("onAppOpenAttribution is:")
if let pid = attributionData[AnyHashable("pid")] as? String{
attDataString.append("PID: " + pid + "\n\n")
print(helper(module: "pid", message: pid))
}
if let is_retargeting = attributionData[AnyHashable("is_retargeting")] as? String{
attDataString.append("is_retargeting: " + is_retargeting + "\n\n")
print(helper(module: "is_retargeting", message: is_retargeting))
}
if let campaign = attributionData[AnyHashable("c")] as? String{
attDataString.append("Campaign: " + campaign + "\n\n")
print(helper(module: "campaign", message: campaign))
}
if let link = attributionData[AnyHashable("link")] as? String{
attDataString.append("Link: " + link + "\n\n")
print(helper(module: "link", message: link))
}
if let af_dp = attributionData[AnyHashable("af_dp")] as? String{
attDataString.append("af_dp: " + af_dp + "\n\n")
print(helper(module: "af_dp", message: af_dp))
}
print(attributionData)
print("<-------------------------------------------------->")
print("")
// dump(attributionData)
}
func helper(module:String!, message:String!) -> String!{
var sb:String = ""
sb.append(" " + module + "=")
var pad:Int = 17 - module.characters.count
while pad > 0 {
pad-=1
sb.append( " " )
}
sb.append(" " + message)
return sb
}