Implement Firebase inside of a Library(在库中实现 Firebase)
问题描述
我想在我想在许多应用程序中用作 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在库中实现 Firebase
基础教程推荐
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
