android:库模块中的fcm [英] android: fcm in library module

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

问题描述

我面临将Firebase Cloud Messaging集成到库模块中的怪异问题.我正在做一个图书馆项目,在其中我需要处理来自图书馆本身的FCM服务器发出的通知.我不知道是否有可能.

I am facing a weird issue integrating Firebase Cloud Messaging in a library module. I am working on a library project in which I need to handle notifications right coming from the FCM Server from the library itself. I am not aware if it is possible or not.

我遵循的步骤:

  • 我在Firebase控制台上创建了Project.
  • 在项目内部,我用与库包相同的包创建了应用程序.
  • 我下载了google-services.json并将其放在库模块中.
  • 我已将依赖项应用到库模块的gradle中.
  • 现在,我已经在app模块中初始化了我的库模块.我也从FirebaseInstanceIdService获取生成的设备令牌的日志.
  • I created Project on Firebase Console.
  • Inside the project, I created app with package same as my library package.
  • I downloaded and put google-services.json in library module.
  • I have applied the dependency in gradle of library module.
  • Now, I have initialized my library module in app module. I am also getting log of generated device token from FirebaseInstanceIdService.

问题:当我尝试从Firebase控制台发送推送时,没有收到任何通知.

Problem: When I try to send push from Firebase Console, I am not receiving any Notification.

有人遇到过这样的问题,可以帮助我吗?

Have anyone faced such issue and could help me with this ?

推荐答案

因此,经过反复尝试和尝试后,我成功获得了通知.

So, after running a lot through trial and error method, I succeeded in getting Notifications.

注意事项:

  • 您不能仅将Firebase Cloud Notifications集成到库模块中.
  • 将使用此库模块的客户端应用程序模块将在其目录中具有google-services.json文件,而不是在库模块目录中.
  • 客户端应用模块gradle将在其下一行,而不在库模块gradle中:
  • You cannot just integrate Firebase Cloud Notifications in library module.
  • Client app module who will be using this library module will have google-services.json file in his directory and not in library module directory.
  • Client app module gradle will be having below line in it and not in library module gradle:

应用插件:"com.google.gms.google-services"

apply plugin: 'com.google.gms.google-services'

因此,一旦我完成了这两项更改,便可以获取通知.

So, once I made those two changes, I was able to get Notifications.

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

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