Personalizing invites in the app using AppsFlyer

Everyone who has built user interaction with the application knows how difficult it is. One of the mechanisms for this interaction is Deep Linking. Push notifications, user acquisition and retention depend on his work.





AppsFlyer , .





SDK

AppsFlyer β€” . .





SDK β€” .





, . onConversionDataSuccess



.





override fun onConversionDataSuccess(map: MutableMap<String, Any>?) {
	Timber.d("Attribution - ${map ?: "empty"}")
  if (map.isNullOrEmpty()) {
  	return
  }
  //handle attribution here
      
      



. , .





Β«Attribution – emptyΒ». :





  1. AppsFlyer.





  2. AppsFlyer, , debug .





  3. .





, AppsFlyer , ( debbuger):





Example of atyribution after installation

map. , , http_referrer , , is_first_launch . 





af_dp β€” , id β€” hSPRMKbU8. id, β€” .





, , .





  1. . , . , , β€” . , .





  2. , , , . 2 15 . UI, , β€” . , , . 





, , ! .





, . , . , - , β€” . 





AppsFlyer API , . , , SDK . β€” LinkGenerator.





with(generator) {
  setReferrerName("user nick")
  setReferrerUID("user unique id")
  setReferrerImageURL("user avatar url")
  addParameter("is_retargeting", true.toString())
  addParameter("af_dp", "link for content in application")
  addParameter("af_web_dp", "additional link for web page")
  generateLink(context, listener)
}
      
      



, Google Play , , .





, . β€” , . , .





-, intent-filter.





<intent-filter anroid:autoVerify="true">
  <action android:name="android.intent.action.VIEW" />
  <category android:name="android.intent.category.DEFAULT" />
  <category android:name="android.intent.category.BROWSABLE" />
  <data android:scheme="https"
        android:host="${oneLinkAppHost}"
        android:prefix="/${oneLinkPathPrefix}" />
</intent-filter>
      
      



-, onAppOpenAttribution. , .





override fun onAppOpenAttribution(map: MutableMap<String, String>?) {
  if (map.isNullOrEmpty()) {
    return
  }
  val data = AppsFlyerConversionAttrs.init(map as Map<String, Any>)
  if (!TextUtils.isEmpty(data.afDeeplink)) {
    handleDeeplink(data.afDeeplink)
  }
}
      
      



, , onConversionDataSuccess . 





. : -, . . 





, :





  1. -.





  2. - .





. , -, . , : id, .





private val inviteLinkPlaceholder = "Click this link to add %1$s as friend"

private val listener = object : CreateOneLinkHttpTask.ResponseListener {
  override fun onResponse(inviteLink: String?) {
    if (!TextUtils.isEmpty(inviteLink)) {
      generatedLinkSubject.onNext(String.format(inviteLinkPlaceholder, 
                                                authSessionManager.authSession.nick,
                                                inviteLink))
    } else {
      generatedLinkSubject.onNext("")
    }
  }
  
  override fun onResponseError(p0: String?) {
    generatedLinkSubject.onNext(p0 ?: "")
  }
}

fun generate(content: Content): Observable<String> {
    generatedLinkSubject = PublishSubject.create()
  with(generator) {
    setReferrerName(authSessionManager.authSession.nick)
    setReferrerUID(authSessionManager.authSession.uid)
    setReferrerImageURL(authSessionManager.authSession.photoUrl)
    addParameter("is_retargeting", true.toString())
    addParameter("af_dp", content.link)
    addParameter("af_web_dp", content.webLink)
    generateLink(context, listener)
  }
  return generatedLinkSubject
}
      
      



: Click this link to add Rick_Rick as friend in ABPV https://abpv.onelink.me/nWMv/344e6258, .





, , , , .





.





onConversionDataSuccess -. media_source, af_app_invites.





if (data.afMediaSource == "af_app_invites") {
    //handle data from invite link
  onInstallationAttributionSubject.onNext(ACTION_PERFORMED)
}
      
      



onInstallationAttributionSubject, subject.





Final invitation screen

 

, , .





, - .





, AppsFlyer , , , .








All Articles