跳转到内容

Android SDK

请按照以下指南输入 FlareLane 发送推送通知所需的凭据。

dependencyResolutionManagement {
repositories {
// Add the line below
maven("https://jitpack.io")
}
}

将以下内容添加到您的应用级 build.gradle<project>/<app>/build.gradle)中。

dependencies {
// Add the line below
implementation("com.github.flarelane:flarelane-android-sdk:1.10.0")
}

在您的 AndroidManifest.xml 文件中设置 android.name=".MainApplication",然后使用编辑器的快速修复功能创建 MainApplication 类文件。您也可以手动创建该类文件。

Android Studio 编辑器中打开的 AndroidManifest.xml,正在创建 MainApplication 类

onCreate 方法内添加 FlareLane.initWithContext 函数。您可以在控制台的 [项目] 页面找到您的项目 ID。

import com.flarelane.FlareLane
class MainApplication : Application() {
override fun onCreate() {
super.onCreate()
// Add the code below
// To control when the notification permission prompt appears, set the third parameter to false and call .subscribe() at the appropriate time.
FlareLane.initWithContext(this, "PROJECT_ID", true)
}
}

应用安装后,FlareLane 中创建的设备是「匿名设备」。通过关联您单独管理的唯一用户 ID,您可以将 FlareLane 的设备与您自己的用户 ID 进行匹配。

关联用户 ID 有诸多好处。 它可以让您区分会员与非会员,并随时按用户 ID 发送推送通知,因此我们建议您在集成早期就完成设置。

通常情况下,您可以在用户注册或成功登录时,通过 setUserId 函数关联用户 ID。

FlareLane.setUserId(this, "USER_ID")
  • 默认情况下,FlareLane 会在点击推送通知时自动处理 https 链接和深度链接等 URL。 如果您需要实现自己的点击处理逻辑,请参阅禁用自动 URL 处理
<resources>
<!-- Change the notification color -->
<string name="flarelane_notification_accent_color">#BC0000</string>
</resources>
指南
移动 SDK 参考文档
Android SDK 版本说明