API heredadas de iOS
Enlaces profundos directos
Overview
Los enlaces profundos directos dirigen a los usuarios móviles a una actividad o contenido específico dentro de una aplicación, si la aplicación ya está instalada.
Este enrutamiento in-app a una actividad específica en la aplicación es posible gracias a los parámetros que se transmiten a la aplicación cuando el sistema operativo abre la aplicación y se llama al método onAppOpenAttribution
method is called. AppsFlyer's OneLink ensures that the correct value is passed along with the user's click, thus personalizing the user’s app experience.
Only the deep_link_value
is required for deep linking. However, other parameters and values (such as custom attribution parameters) can also be added to the link and returned by the SDK as deep linking data.
El flujo de enlace profundo directo funciona de la siguiente manera:
-
El usuario hace clic en la URL corta de OneLink.
-
iOS lee los derechos de dominios asociados de la aplicación.
-
iOS abre la aplicación.
-
El SDK de AppsFlyer se activa dentro de la aplicación.
-
El SDK de AppsFlyer recupera los datos de OneLink.
- En una URL corta, los datos se recuperan de la API de resolución de URL corta en los servidores de AppsFlyer.
- En una URL larga, los datos se recuperan directamente de la URL larga.
-
AppsFlyer SDK triggers
onAppOpenAttribution()
with the retrieved parameters and cached attribution parameters (e.g.install_time
). -
Asynchronously,
onConversionDataSuccess()
is called, holding the full cached attribution data. (You can exit this function by checking ifis_first_launch
istrue
.) -
onAppOpenAttribution()
utiliza el mapaattributionData
para enviar otras actividades en la aplicación y transmitir los datos relevantes.- Esto crea la experiencia personalizada para el usuario, que es el objetivo principal de OneLink.
Procedures
To implement the onAppOpenAttribution
y configurar los comportamientos de los parámetros, se debe completar la siguiente lista de verificación de acciones de los procedimientos.
Lista de verificación de procedimientos
- Decidir el comportamiento de las aplicaciones y el
deep_link_value
(and other parameter names and values) - with the marketer - Planificar el método de entrada, p. ej.
deep_link_value
(and other parameter names and values) - with the marketer - Implementar la lógica
onAppOpenAttribution()
logic - Implementar la lógica
onAttributionFailure()
logic
Decidir el comportamiento de la aplicación
Para decidir cuál es el comportamiento de la aplicación cuando se hace clic en el enlace:
Obtener del marketer: el comportamiento esperado del enlace cuando se hace clic en él.
Planificar la entrada del método
When a OneLink is clicked and the user has the app installed on their device, the onAppOpenAttribution
method is called by the AppsFlyer SDK. This is referred to as a retargeting re-engagement.
The onAppOpenAttribution
obtiene las variables en una entrada como esta: AnyHashable: Any
.
La estructura de los datos de entrada se describe aquí.
Implementación de la lógica onAppOpenAttribution()
The deep link opens the onAppOpenAttribution
en la actividad principal. Los parámetros de OneLink en la entrada del método se utilizan para implementar la experiencia de usuario específica cuando se abre la aplicación.
Ejemplo de código:
func onAppOpenAttribution(_ attributionData: [AnyHashable: Any]) {
//Handle Deep Link Data
print("onAppOpenAttribution data:")
for (key, value) in attributionData {
print(key, ":",value)
}
walkToSceneWithParams(params: attributionData)
}
// User logic
fileprivate func walkToSceneWithParams(params: [AnyHashable:Any]) {
let storyBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
UIApplication.shared.windows.first?.rootViewController?.dismiss(animated: true, completion: nil)
var fruitNameStr = ""
if let thisFruitName = params["deep_link_value"] as? String {
fruitNameStr = thisFruitName
} else if let linkParam = params["link"] as? String {
guard let url = URLComponents(string: linkParam) else {
print("Could not extract query params from link")
return
}
if let thisFruitName = url.queryItems?.first(where: { $0.name == "deep_link_value" })?.value {
fruitNameStr = thisFruitName
}
}
let destVC = fruitNameStr + "_vc"
if let newVC = storyBoard.instantiateVC(withIdentifier: destVC) {
print("AppsFlyer routing to section: \(destVC)")
newVC.attributionData = params
UIApplication.shared.windows.first?.rootViewController?.present(newVC, animated: true, completion: nil)
} else {
print("AppsFlyer: could not find section: \(destVC)")
}
}
⇲ Enlaces de Github: Swift
Implementar la lógica onAttributionFailure()
The onAttributionFailure
method is called whenever the call to onAppOpenAttribution
fails. The function should report the error and create an expected experience for the user.
func onAppOpenAttributionFailure(_ error: Error) {
print("\(error)")
}
⇲ Enlaces de Github: Swift
Enlaces profundos diferidos
Importante
Los enlaces profundos diferidos que utilizan el método heredado de onConversionDataSuccess pueden no funcionar para iOS 14.5+, ya que requieren datos de atribución que pueden no estar disponibles debido a la protección de la privacidad.
Recomendamos utilizar enlaces profundos unificados (UDL). El UDL cumple con los estándares de privacidad de iOS 14.5+ y solo devuelve parámetros relevantes para los enlaces profundos y enlaces profundos diferidos:deep_link_value
anddeep_link_sub1-10
. Los parámetros de atribución (comomedia_source
,campaign
,af_sub1-5
, etc.), devuelvenull
y no se puede utilizar para propósitos de enlaces profundos.
Aprender más
Overview
El Deferred Deep Linking dirige a los nuevos usuarios primero a la tienda de aplicaciones correcta para instalar la aplicación y luego, después de la primera apertura, a una experiencia específica de la aplicación (por ejemplo, una página específica en la aplicación).
When the user first launches the app, the onConversionDataSuccess
callback function receives both the conversion data of the new user, and OneLink data. The OneLink data makes in-app routing possible due to the deep_link_value
u otro que se transmite a la aplicación cuando el sistema operativo abre la aplicación.
Only the deep_link_value
is required for deep linking. However, other parameters and values (such as custom attribution parameters) can also be added to the link and returned by the SDK as deep linking data. The AppsFlyer OneLink ensures that the correct parameters are passed along with the user's click, thus personalizing the user’s app experience.
The marketer and developer must coordinate regarding desired app behavior and deep_link_value
. The marketer uses the parameters to create deep links, and the developer customizes the behavior of the app based on the value received.
Es responsabilidad del desarrollador asegurarse de que los parámetros se manejen correctamente en la aplicación, tanto para el enrutamiento dentro de la aplicación como para personalizar los datos en el enlace.
El flujo de enlace profundo diferido funciona de la siguiente manera:
- El usuario hace clic en el OneLink en un dispositivo en el que la aplicación no está instalada.
- AppsFlyer registra el clic y redirige el usuario a la tienda de aplicaciones o la página de aterrizaje correctas.
- El usuario instala la aplicación y la inicia.
- El SDK de AppsFlyer se inicializa y la instalación se atribuye en los servidores de AppsFlyer.
- The SDK triggers the
onConversionDataSuccess
method. The function receives input that includes both thedeep_link_value
, and the attribution data/parameters defined in the OneLink data. - El parámetro
is_first_launch
has the valuetrue
, que indica el flujo de Deferred Deep Linking.
El desarrollador utiliza los datos recibidos en elonConversionDataSuccess
para crear una experiencia personalizada para el usuario en la primera apertura de la aplicación.
Procedures
To implement the onConversionDataSuccess
method and set up the parameter behaviors, the following action checklist of procedures need to be completed.
- Decidir el comportamiento de la aplicación en el primer inicio, y el
deep_link_value
(and other parameter names and values) - with the marketer - Planificar el método de entrada, p. ej.
deep_link_value
(and other parameter names and values) - with the marketer - Implementar la lógica
onConversionDataSuccess()
logic - Implementar la lógica
onConversionDataFail()
logic
Decidir el comportamiento de la aplicación en el primer inicio
Para decidir el comportamiento de la aplicación en el primer inicio:
Obtener del marketer: el comportamiento esperado del enlace cuando se hace clic y la aplicación se abre por primera vez.
Planificar la entrada del método
For deferred deep linking, the onConversionDataSuccess
method input must be planned and the input decided in the previous section (for deep linking) is made relevant for the first time the app is launched.
The onConversionDataSuccess
method gets the deep_link_value
y otras variables como una entrada como esta: AnyHashable: Any
.
El mapa contiene dos tipos de datos:
- Datos de atribución
- Data defined by the marketer in the link (
deep_link_value
and other parameters and values)
Other parameters can be either:- Parámetros oficiales de AppsFlyer.
- Parámetros y valores personalizados elegidos por el marketer y el desarrollador.
- La estructura de los datos de entrada se describe aquí.
The marketer and developers need to plan the deep_link_value
(and other possible parameters and values) together based on the desired app behavior when the link is clicked.
To plan the deep_link_value
, and other parameter names and values based on the expected link behavior:
- Dile al marketer qué parámetros y valores se necesitan para implementar el comportamiento deseado de la aplicación.
- Decide on naming conventions for the
deep_link_value
and other parameters and values.
Note:- Los parámetros personalizados no aparecerán en el raw data recopilado en AppsFlyer.
- Los datos de conversión no devolverán un parámetro personalizado llamado "name, " con una "n" minúscula.
Implementación de la lógica onConversionDataSuccess()
When the app is opened for the first time, the onConversionDataSuccess
method is triggered in the main activity. The deep_link_value
and other parameters in the method input are used to implement the specific user experience when the app is first launched.
Para implementar la lógica:
- Implementa la lógica basada en los parámetros y valores elegidos. Consulta el siguiente ejemplo de código.
- Una vez completado, envía la confirmación al marketer de que la aplicación se comporta en consecuencia.
Código de muestra
// Handle Organic/Non-organic installation
func onConversionDataSuccess(_ data: [AnyHashable: Any]) {
print("onConversionDataSuccess data:")
for (key, value) in data {
print(key, ":", value)
}
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.")
}
if let is_first_launch = data["is_first_launch"] as? Bool,
is_first_launch {
print("First Launch")
if let fruit_name = data["deep_link_value"]
{
// The key 'deep_link_value' exists only in OneLink originated installs
print("deferred deep-linking to \(fruit_name)")
walkToSceneWithParams(params: data)
}
else {
print("Install from a non-owned media")
}
} else {
print("Not First Launch")
}
}
}
⇲ Enlaces de Github: Swift
Implementación de la lógica onConversionDataFailure()
The onConversionDataFailure
method is called whenever the call to onConversionDataSuccess
fails. The function should report the error and create an expected experience for the user.
To implement the onConversionDataFailure
método:
func onConversionDataFail(_ error: Error) {
print("\(error)")
}
⇲ Enlaces de Github: Swift
Cargas útiles de muestra de iOS
Consulta las siguientes cargas útiles de muestra para enlaces universales, esquemas URI y Deferred Deep Linking. Las muestras contienen una carga útil completa, relevante para cuando todos los parámetros de la página de configuración de enlaces personalizados de Onelink contienen datos.
Nota: Las cargas útiles se devuelven como un mapa. Sin embargo, para mayor claridad, las cargas útiles de muestra que siguen se muestran en formato JSON.
Universal Links
Entrada en onAppOpenAttribution(_ attributionData: [AnyHashable: Any])
{
"af_ad": "my_adname",
"af_adset": "my_adset",
"af_android_url": "https://isitchristmas.com/",
"af_channel": "my_channel",
"af_click_lookback": "20d",
"af_cost_currency": "USD",
"af_cost_value": 6,
"af_dp": "afbasicapp://mainactivity",
"af_ios_url": "https://isitchristmas.com/",
"af_sub1": "my_sub1",
"af_sub2": "my_sub2",
"c": "fruit_of_the_month",
"campaign": "fruit_of_the_month",
"fruit_amount": 26,
"fruit_name": "apples",
"is_retargeting": true,
"link": "https://onelink-basic-app.onelink.me/H5hv/6d66214a",
"media_source": "Email",
"pid": "Email"
}
{
"path": "/H5hv",
"af_android_url": "https://my_android_lp.com",
"af_channel": "my_channel",
"host": "onelink-basic-app.onelink.me",
"af_adset": "my_adset",
"pid": "Email",
"scheme": "https",
"af_dp": "afbasicapp://mainactivity",
"af_sub1": "my_sub1",
"fruit_name": "apples",
"af_ad": "my_adname",
"af_click_lookback": "20d",
"fruit_amount": 16,
"af_sub2": "my_sub2",
"link": "https://onelink-basic-app.onelink.me/H5hv?pid=Email&c=fruit_of_the_month&af_channel=my_channel&af_adset=my_adset&af_ad=my_adname&af_sub1=my_sub1&af_sub2=my_sub2&fruit_name=apples&fruit_amount=16&af_cost_currency=USD&af_cost_value=6&af_click_lookback=20d&af_dp=afbasicapp%3A%2F%2Fmainactivity&af_ios_url=https%3A%2F%2Fmy_ios_lp.com&af_android_url=https%3A%2F%2Fmy_android_lp.com",
"af_cost_currency": "USD",
"c": "fruit_of_the_month",
"af_ios_url": "https://my_ios_lp.com",
"af_cost_value": 6
}
URI scheme
Entrada en onAppOpenAttribution(_ attributionData: [AnyHashable: Any])
{
"af_click_lookback ": "25d",
"af_sub1 ": "my_sub1",
"shortlink ": "9270d092",
"af_deeplink ": true,
"media_source ": "Email",
"campaign ": "my_campaign",
"af_cost_currency ": "NZD",
"host ": "mainactivity",
"af_ios_url ": "https://my_ios_lp.com",
"scheme ": "afbasicapp",
"path ": "",
"af_cost_value ": 5,
"af_adset ": "my_adset",
"af_ad ": "my_adname",
"af_android_url ": "https://my_android_lp.com",
"af_sub2 ": "my_sub2",
"af_force_deeplink ": true,
"fruit_amount ": 15,
"af_dp ": "afbasicapp://mainactivity",
"link ": "afbasicapp://mainactivity?af_ad=my_adname&af_adset=my_adset&af_android_url=https%3A%2F%2Fmy_android_lp.com&af_channel=my_channel&af_click_lookback=25d&af_cost_currency=NZD&af_cost_value=5&af_deeplink=true&af_dp=afbasicapp%3A%2F%2Fmainactivity&af_force_deeplink=true&af_ios_url=https%3A%2F%2Fmy_ios_lp.com&af_sub1=my_sub1&af_sub2=my_sub2&af_web_id=56441f02-377b-47c6-9648-7a7f88268130-o&campaign=my_campaign&fruit_amount=15&fruit_name=apples&is_retargeting=true&media_source=Email&shortlink=9270d092",
"af_channel ": "my_channel",
"is_retargeting ": true,
"af_web_id ": "56441f02-377b-47c6-9648-7a7f88268130-o",
"fruit_name ": "apples"
}
{
"af_ad ": "my_adname",
"fruit_name ": "apples",
"host ": "mainactivity",
"af_channel ": "my_channel",
"link ": "afbasicapp://mainactivity?af_ad=my_adname&af_adset=my_adset&af_android_url=https%3A%2F%2Fmy_android_lp.com&af_channel=my_channel&af_click_lookback=25d&af_cost_currency=NZD&af_cost_value=5&af_deeplink=true&af_dp=afbasicapp%3A%2F%2Fmainactivity&af_force_deeplink=true&af_ios_url=https%3A%2F%2Fmy_ios_lp.com&af_sub1=my_sub1&af_sub2=my_sub2&af_web_id=56441f02-377b-47c6-9648-7a7f88268130-o&campaign=my_campaign&fruit_amount=15&fruit_name=apples&is_retargeting=true&media_source=Email",
"af_deeplink ": true,
"campaign ": "my_campaign",
"af_sub1 ": "my_sub1",
"af_click_lookback ": "25d",
"af_web_id ": "56441f02-377b-47c6-9648-7a7f88268130-o",
"path ": "",
"af_sub2 ": "my_sub2",
"af_ios_url ": "https://my_ios_lp.com",
"af_cost_value ": 5,
"fruit_amount ": 15,
"is_retargeting ": true,
"scheme ": "afbasicapp",
"af_force_deeplink ": true,
"af_adset ": "my_adset",
"media_source ": "Email",
"af_cost_currency ": "NZD",
"af_dp ": "afbasicapp://mainactivity",
"af_android_url ": "https://my_android_lp.com"
}
Deferred deep linking
Entrada en onConversionDataSuccess(_ data: [AnyHashable: Any])
{
"adgroup": null,
"adgroup_id": null,
"adset": null,
"adset_id": null,
"af_ad": "my_adname",
"af_adset": "my_adset",
"af_android_url": "https://isitchristmas.com/",
"af_channel": "my_channel",
"af_click_lookback": "20d",
"af_cost_currency": "USD",
"af_cost_value": 6,
"af_cpi": null,
"af_dp": "afbasicapp://mainactivity",
"af_ios_url": "https://isitchristmas.com/",
"af_siteid": null,
"af_status": "Non-organic",
"af_sub1": "my_sub1",
"af_sub2": "my_sub2",
"af_sub3": null,
"af_sub4": null,
"af_sub5": null,
"agency": null,
"campaign": "fruit_of_the_month ",
"campaign_id": null,
"click_time": "2020-08-12 15:08:00.770",
"cost_cents_USD": 600,
"engmnt_source": null,
"esp_name": null,
"fruit_amount": 26,
"fruit_name": "apples",
"http_referrer": null,
"install_time": "2020-08-12 15:08:33.335",
"is_branded_link": null,
"is_first_launch": 1,
"is_retargeting": true,
"is_universal_link": null,
"iscache": 1,
"match_type": "probabilistic",
"media_source": "Email",
"orig_cost": "6.0",
"redirect_response_data": null,
"retargeting_conversion_type": "none",
"shortlink": "6d66214a"
}
Actualizado hace 9 días