问题描述
我想在我想在许多应用程序中用作 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)