3

这是我的项目文件夹结构。


应用/
    FCM/
        FcmMessagingService.class
        FcmRegistrationService.class
   谷歌-services.json
   的Android的Manifest.xml

Android的的Manifest.xml
Android库项目中的Firebase云消息传递。

<service android:name=".fcm.FcmRegistrationService"> 
     <intent-filter> 
      <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/> 
     </intent-filter> 
</service> 

<service android:name=".fcm.FcmMessagingService"> 
     <intent-filter> 
      <action android:name="com.google.firebase.MESSAGING_EVENT"/> 
     </intent-filter> 
</service> 

库(子模块)/
    FCM/
        LibMessagingService.class
        LibRegistrationService.class
   穿心莲内酯ID-的Manifest.xml

Android系统的Manifest.xml

<service android:name=".fcm.LibRegistrationService"> 
      <intent-filter> 
       <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/> 
      </intent-filter> 
</service> 

<service android:name=".fcm.LibMessagingService"> 
      <intent-filter> 
       <action android:name="com.google.firebase.MESSAGING_EVENT"/> 
      </intent-filter> 
</service> 

通过以上的实施,我可以能够捕捉到INSTANCE_ID_EVENT和MESSAGING_EVENT,只有从应用程序的服务类。库模块中的Firebase服务类完全没有触发。

是否有可能同时触发两个应用程序和库模块,接收到的消息火力点当服务类?

+0

您是否找到了解决方案? – Blagojco

+2

@Blagojco是的,我发现周围的工作这一点。在我的图书馆,我添加的实际FCM服务和应用程序的FCM服务类将延长我的图书馆的FCM服务,而不是谷歌的FCM服务。 – Karthik

回答

0

我没有实现它库模块上的任何问题。 我只是实现了所有的服务,在图书馆和客户机清单申报。这就是我的项目的样子: enter image description here

google-services.json文件位于客户端应用程序目录中。 客户端build.gradle文件中有apply plugin: 'com.google.gms.google-services'

0

太使它工作我也必须在库清单以及应用程序清单中注册库服务。试图找出哪些实际上是需要的

`<service 
    android:name="com.libPackage.FCMService"> 
    <intent-filter> 
     <action android:name="com.google.firebase.MESSAGING_EVENT"/> 
    </intent-filter> 
</service>` 
相关问题