跳到主要内容

APP 玩法

最后更新:2024/04/03

定义接入活动所对应的SDK接口

打开活动页面

TurboLink.Campaign.loadUrl(this, "<活动渠道链接URL>")
.withLoginActivityRef(LoginActivity::class) //定义没有登录时打开登录页面的引用
.withEventListenerCallback(object : CampaignBuilder.EventListenerCallback { //定义事件触发时对自定义事件处理的回调流程
override fun onSuccess(campaignActivity: Context, listenerEventProperties: ListenerEventProperties) {
//when (listenerEventProperties.getScheme()) {
// "payment" -> {
// val paymentIntent = Intent(campaignActivity, PayActivity::class.java)
// campaignActivity.startActivity(paymentIntent)
// }
//}
}
})
.build()

withEventListenerCallback 为活动中事件触发的回调,返回ListenerEventProperties, 我们再根据事件跳转到想引导到的页面。
ListenerEventProperties 结构参考

当用户没有登录时,会跳转到登录界面, 用户完成APP侧的登录操作需要调用SDK的登录事件:

TurboLink.DefaultEvent.login(this, "<你的app用户ID/加密后的用户ID>")
.build(object : TurboLinkEvent.TurboLinkEventCallback {
override fun onSuccess(response: EventResponse) {
//这里不需要再调用活动的loadUrl, SDK会自动跳转到未登录的活动页
}

override fun onFailure(code: Int, msg: String) {
}
})

监听回调

点击自定义事件监听回调

TurboLink.withEventListenerCallback(object : CampaignBuilder.EventListenerCallback {
override fun onSuccess(
campaignActivity: Context,
listenerEventProperties: ListenerEventProperties
) {
//根据ListenerEventProperties返回执行触发活动事件的流程,如:ListenerEventProperties返回的自定义的充值事件,则这里跳到充值Activity.
}
})

ListenerEventProperties 结构参考

活动页面点击事件埋点回调

TurboLink.withPointListenerCallback(object : CampaignBuilder.PointListenerCallback {
override fun onSuccess(
campaignActivity: Context,
listenerPointProperties: ListenerPointProperties
) {

}
})

ListenerPointProperties结构参考
埋点监听位置说明

活动页面组件跳转监听埋点回调

TurboLink.withRedirectListenerCallback(object : CampaignBuilder.RedirectListenerCallback {
override fun onSuccess(
campaignActivity: Context,
listenerRedirectProperties: ListenerRedirectProperties
) {
// TurboLinkLogger.e("redirect:" + listenerRedirectProperties.getCampaignId() + "_"
// + listenerRedirectProperties.getCampaignTitle() + "_"
// + listenerRedirectProperties.getCampaignLang() + "_"
// + listenerRedirectProperties.getCampaignUrl() + "_"
// + listenerRedirectProperties.getUser() + "_"
// + listenerRedirectProperties.getType() + "_"
// + listenerRedirectProperties.getAppUrl() + "_"
// + listenerRedirectProperties.getRewardInfo()?.geTitle() + "_"
// + listenerRedirectProperties.getRewardInfo()?.getKvData()?.get(0)?.getKey() + "_"
// + listenerRedirectProperties.getRewardInfo()?.getKvData()?.get(0)?.getValue() + "_"
// + listenerRedirectProperties.getRewardInfo()?.getKvData()?.get(1)?.getKey() + "_"
// + listenerRedirectProperties.getRewardInfo()?.getKvData()?.get(1)?.getValue() + "_"
// )
}

})

社媒分享监听回调

注意:实现该回调需要自己自定义社媒拉起能力。
TurboLink.withShareListenerCallback(object : CampaignBuilder.ShareListenerCallback {
override fun onSuccess(
campaignActivity: Context,
listenerShareProperties: ListenerShareProperties
) {
//这里可以根据listenerShareProperties对象来做业务处理
}
})

listenerShareProperties 结构参考

登录监听回调

TurboLink.withLoginListenerCallback(object : CampaignBuilder.LoginListenerCallback {
override fun onSuccess(campaignActivity: Context) {
//回调的登录业务代码
}
})

注册监听回调

TurboLink.withRegListenerCallback(object : CampaignBuilder.RegListenerCallback {
override fun onSuccess(campaignActivity: Context) {
//回调的注册业务代码
}
})

活动页创建回调

TurboLink.withCampaignCreateCallback(object : CampaignBuilder.CampaignCreateCallback {
override fun onSuccess(campaignActivity: Context) {
}
})

活动页Destroy回调

TurboLink.withCampaignDestroyCallback(object : CampaignBuilder.CampaignDestroyCallback {
override fun onSuccess(campaignActivity: Context) {
}
})

定义自动拉起活动页时机

设置能自动拉起活动页的Activity列表

对应用户点击是活动的链接,会自动拉起APP并自动打开活动页,但APP侧希望在特定的页面加载时才自动打开,可以使用这个方法,可以设置多个Activity。

// 设置初始化SDK方法(TurboLink.autoInstance)前
TurboLink.Campaign.setLaunchCampaignActivity(MainActivity::class)
.setLaunchCampaignActivity(LoginActivity::class)

设置延迟自动拉起活动页

对应用户点击是活动的链接,会自动拉起APP并自动打开活动页,但有些场景下,APP侧希望能延迟几秒钟再打开。这是可以使用这个方法。单位:秒(s)

// 等待2秒后再拉起活动页
// 设置初始化SDK方法(TurboLink.autoInstance)前
TurboLink.Campaign.setLaunchCampaignDelay(2)

WebView样式

设置活动页允许横竖屏

默认是竖屏,可以通过该方法设置允许横竖屏

TurboLink.Campaign.setScreenOrientationAll()

设置为深色模式

TurboLink.Campaign.setNightMode(true)

设置为未加载标题

TurboLink.Campaign.setInitTitle("Loading...")

不显示回退按钮

TurboLink.Campaign.setGoneBack(true)

设置标题字体大小

TurboLink.Campaign.setTitleSize(16f)

判断活动链接是否是TurboLink的

TurboLink.isUrlBelongTurboLink("<活动链接>")

获取活动详情

TurboLink.Campaign.getCampaignInfo("<活动ID>", "<LinkHashId(归因返回,可为空)>").build(object : CampaignInfo.TurboLinkCampaignCallback {
override fun onSuccess(response: CampaignInfoProperties) {
TurboLinkLogger.e("campaignId:" + response.getCampaignId()
+ "_" + response.getTitle() + "_" + response.getLangs()
+ "_" + response.getLink() + "_" + response.getStart()
+ "_" + response.getEnd() + "_" + response.getUtm()
+ "_" + response.getStatus())
}

override fun onFailure(code: Int, msg: String) {
}
})

CampaignInfoProperties 结构参考