我正在尝试自定义“仅图像”和“模式”模式的 firebase in-app-messaging-display 用户界面。所以我转向官方文档,但它很简单,说: 创建您自己的显示是一个两步过程: 1.编写您自己的 FirebaseInAppMessagingDisplay 类的实现。 2.使用 headless Firebase 应用内消息 SDK 注册该实现。
我想知道如何将 in-app-messaging-display 的源代码导入到我的项目中并使其作为一个库运行。
我已经从github上下载了它的源代码:https://github.com/firebase/firebase-android-sdk/tree/master/firebase-inappmessaging-display ,尝试将其作为模块导入,但在我选择源目录后,Android Studio 提示:Specify location of the Gradle 或 Android Eclipse 项目。我还尝试将源代码复制到我的项目的 libs 目录中并添加了这个:包括':libs:firebase-inappmessaging-display'到我的 settings.gradle 文件和这个:实现项目(':libs:firebase-inappmessaging-display ') 到我的应用程序的 gradle 依赖项中。同步构建Android Studio时报错如下: 错误:无法解析“:XXXXXXXX”的依赖项:无法解析项目:libs:firebase-inappmessaging-display。
任何建议将不胜感激。
最佳答案
文档上的信息有点困惑。我也被同样的问题困扰了很长时间。其实很简单。
在您的应用级 gradle 文件中添加这些依赖项。
implementation 'com.google.firebase:firebase-core:16.0.8'
implementation ("com.google.firebase:firebase-inappmessaging:17.0.3")
在开始 Activity 时注册您的 DisplayMessage 组件。
import com.google.firebase.inappmessaging.FirebaseInAppMessaging
import com.google.firebase.inappmessaging.FirebaseInAppMessagingDisplay
///////
override fun onStart() {
super.onStart()
Log.e("MESSAGE", "activity started")
var firebaseInAppMessagingDisplay = FirebaseInAppMessagingDisplay { inAppMessage, cb ->
// You can show the message here.
// The variable inAppMessage has all information about the campaign that we putting in console (title, content, image url.. etc)
Log.e("MESSAGE", "Display Message callback invoked")
}
FirebaseInAppMessaging.getInstance().setMessageDisplayComponent(firebaseInAppMessagingDisplay)
}
关于android - 如何将 firebase in-app-messaging-display api 的源代码导入到我的 android 项目中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54737855/