我想在我想在许多应用程序中用作 SDK 的库中实现 Friebase 通知系统.
I want to implement Friebase notifications system inside a library that I want to use as SDK in many apps.
Firebase 现在要求提供应用 ID,但我在库中实现它,因此没有应用 ID.
Firebase is asking now for an App ID, but I'm implementing it inside a library thus no App Id.
如何实现向使用我的库的应用发送通知的目标?
How could I achieve my goal to be able to send notifications to my apps that use my library ?
提前致谢.
是的,您实际上可以这样做,在您的库中 build.gradle
将其放在 defaultConfig 字段中
Yes you can actually do this, on your library build.gradle
put this inside the defaultConfig field
buildConfigField("String", "FIREBASE_APP_KEY", ""${firebaseAppKey}"")
然后在你项目的 gradle.properties
firebaseAppKey = <yourFirebaseAppSecret>;
对于 每个 项目/应用,您必须在 gradle.properties
上定义此变量.
For each project/app you must define this variable on your gradle.properties
.
您必须为每个项目创建一个 Firebase 应用,但您的库现在可以拥有 Firebase SDK.
You'll have to create a firebase app for each project, but your library can now have the Firebase SDK.
当您想访问此环境变量值时,请使用 BuildConfig.FIREBASE_APP_KEY
(例如,实例化 firebase).
When you want to access this environment variable value use BuildConfig.FIREBASE_APP_KEY
(e.g. instantiate firebase).
这篇关于在库中实现 Firebase的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!