APP 玩法
最后更新:2024/04/03
定义接入活动所对应的SDK接口
打开活动页面
- Kotlin
- Java
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()
TurboLink.Campaign.loadUrl(this, "<活动渠道链接URL>")
.withLoginActivityRef(kotlin.jvm.JvmClassMappingKt.getKotlinClass(LoginActivity.class))
.withEventListenerCallback(new CampaignBuilder.EventListenerCallback() {
@Override
public void onSuccess(@NonNull Context campaignActivity, @NonNull ListenerEventProperties listenerEventProperties) {
}
}).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) {
}
})
监听回调
点击自定义事件监听回调
- Kotlin
- Java
TurboLink.withEventListenerCallback(object : CampaignBuilder.EventListenerCallback {
override fun onSuccess(
campaignActivity: Context,
listenerEventProperties: ListenerEventProperties
) {
//根据ListenerEventProperties返回执行触发活动事件的流程,如:ListenerEventProperties返回的自定义的充值事件,则这里跳到充值Activity.
}
})
TurboLink.withEventListenerCallback(new CampaignBuilder.EventListenerCallback() {
@Override
public void onSuccess(@NonNull Context campaignActivity, @NonNull ListenerEventProperties listenerEventProperties) {
// 执行触发活动事件的流程
// campaignActivity - 活动页对应的activity
// listenerEventProperties - 触发的事件信息
}
});
活动页面点击事件埋点回调
- Kotlin
- Java
TurboLink.withPointListenerCallback(object : CampaignBuilder.PointListenerCallback {
override fun onSuccess(
campaignActivity: Context,
listenerPointProperties: ListenerPointProperties
) {
}
})
TurboLink.withPointListenerCallback(new CampaignBuilder.PointListenerCallback() {
@Override
public void onSuccess(@NonNull Context campaignActivity, @NonNull ListenerPointProperties listenerPointProperties) {
}
});
ListenerPointProperties结构参考
埋点监听位置说明
活动页面组件跳转监听埋点回调
- Kotlin
- Java
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.withRedirectListenerCallback(new CampaignBuilder.RedirectListenerCallback() {
@Override
public void onSuccess(@NonNull Context campaignActivity, @NonNull ListenerRedirectProperties listenerRedirectProperties) {
// TurboLinkLogger.e("withRedirectListenerCallback " + listenerRedirectProperties.getRewardInfo().geTitle());
}
});
社媒分享监听回调
注意:实现该回调需要自己自定义社媒拉起能力。- Kotlin
- Java
TurboLink.withShareListenerCallback(object : CampaignBuilder.ShareListenerCallback {
override fun onSuccess(
campaignActivity: Context,
listenerShareProperties: ListenerShareProperties
) {
//这里可以根据listenerShareProperties对象来做业务处理
}
})
TurboLink.withShareListenerCallback(new CampaignBuilder.ShareListenerCallback() {
@Override
public void onSuccess(@NonNull Context campaignActivity, @NonNull ListenerShareProperties listenerShareProperties) {
//这里可以根据listenerShareProperties对象来做业务处理
}
});
登录监听回调
- Kotlin
- Java
TurboLink.withLoginListenerCallback(object : CampaignBuilder.LoginListenerCallback {
override fun onSuccess(campaignActivity: Context) {
//回调的登录业务代码
}
})
TurboLink.withLoginListenerCallback(new CampaignBuilder.LoginListenerCallback(){
@Override
public void onSuccess(@NonNull Context campaignActivity) {
//回调的登录业务代码
}
});
注册监听回调
- Kotlin
- Java
TurboLink.withRegListenerCallback(object : CampaignBuilder.RegListenerCallback {
override fun onSuccess(campaignActivity: Context) {
//回调的注册业务代码
}
})
TurboLink.withRegListenerCallback(new CampaignBuilder.RegListenerCallback() {
@Override
public void onSuccess(@NonNull Context campaignActivity) {
//回调的注册业务代码
}
});
活动页创建回调
- Kotlin
- Java
TurboLink.withCampaignCreateCallback(object : CampaignBuilder.CampaignCreateCallback {
override fun onSuccess(campaignActivity: Context) {
}
})
TurboLink.withCampaignCreateCallback(new CampaignBuilder.CampaignCreateCallback() {
@Override
public void onSuccess(@NonNull Context campaignActivity) {
}
});
活动页Destroy回调
- Kotlin
- Java
TurboLink.withCampaignDestroyCallback(object : CampaignBuilder.CampaignDestroyCallback {
override fun onSuccess(campaignActivity: Context) {
}
})
TurboLink.withCampaignDestroyCallback(new CampaignBuilder.CampaignDestroyCallback() {
@Override
public void onSuccess(@NonNull Context campaignActivity) {
}
});
定义自动拉起活动页时机
设置能自动拉起活动页的Activity列表
对应用户点击是活动的链接,会自动拉起APP并自动打开活动页,但APP侧希望在特定的页面加载时才自动打开,可以使用这个方法,可以设置多个Activity。
- Kotlin
- Java
// 设置初始化SDK方法(TurboLink.autoInstance)前
TurboLink.Campaign.setLaunchCampaignActivity(MainActivity::class)
.setLaunchCampaignActivity(LoginActivity::class)
TurboLink.Campaign.setLaunchCampaignActivity(kotlin.jvm.JvmClassMappingKt.getKotlinClass(MainActivity.class));
设置延迟自动拉起活动页
对应用户点击是活动的链接,会自动拉起APP并自动打开活动页,但有些场景下,APP侧希望能延迟几秒钟再打开。这是可以使用这个方法。单位:秒(s)
- Kotlin
- Java
// 等待2秒后再拉起活动页
// 设置初始化SDK方法(TurboLink.autoInstance)前
TurboLink.Campaign.setLaunchCampaignDelay(2)
TurboLink.Campaign.setLaunchCampaignDelay(2);
WebView样式
设置活动页允许横竖屏
默认是竖屏,可以通过该方法设置允许横竖屏
- Kotlin
- Java
TurboLink.Campaign.setScreenOrientationAll()
TurboLink.Campaign.setScreenOrientationAll();