在库中实现Firebase [英] Implement Firebase inside of a Library

查看:149
本文介绍了在库中实现Firebase的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在一个库中实现Friebase通知系统,我想在许多应用程序中用作SDK。

Firebase现在要求提供应用ID,但是我正在库中实施,因此没有应用ID。



我怎么能达到我的目标,能够发送通知给我的应用程序使用我的图书馆?



在此先感谢。

解决方案

,在你的库 build.gradle 把它放在defaultConfig字段里面

  buildConfigField(String,FIREBASE_APP_KEY,\$ {firebaseAppKey} \)



<然后在你的项目的 gradle.properties



firebaseAppKey =< yourFirebaseAppSecret>;



对于每个项目/应用程序,您必须在 gradle.properties中定义此变量



您必须为每个项目创建一个Firebase应用,但您的图书馆现在可以拥有Firebase SDK。 b
$ b

当你想访问这个环境变量值时,使用 BuildConfig.FIREBASE_APP_KEY
(例如实例化firebase)。


I want to implement Friebase notifications system inside a library that I want to use as SDK in many apps.

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 ?

Thanks in advance.

解决方案

Yes you can actually do this, on your library build.gradle put this inside the defaultConfig field

buildConfigField("String", "FIREBASE_APP_KEY", "\"${firebaseAppKey}\"")

Then inside your project's gradle.properties

firebaseAppKey = <yourFirebaseAppSecret>;

For each project/app you must define this variable on your gradle.properties.

You'll have to create a firebase app for each project, but your library can now have the Firebase SDK.

When you want to access this environment variable value use BuildConfig.FIREBASE_APP_KEY (e.g. instantiate firebase).

这篇关于在库中实现Firebase的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆