How to enable Firebase Cloud Messaging (FCM) for chromium

697 views
Skip to first unread message

Андрей Караман

unread,
Dec 23, 2016, 10:55:02 AM12/23/16
to Chromium-dev
Hi all

Is that possible or maybe there are some exaples how to implement Firebase Cloud Messaging into Chromium?

I tried different ways and now FireBase Analitycs works fine.


Servises are from Firebase docs and after that trying to get token
   FirebaseOptions options = FirebaseOptions.fromResource(this);
   
FirebaseApp.initializeApp(this, options);
   
String token = FirebaseInstanceId.getInstance().getToken();  << Here token always null
   FirebaseMessaging.getInstance().subscribeToTopic("tests");  << that theme is not registered in Firebase console

Tried to clear data and delete token manually - but nothing happen.
FirebaseInstanceId.getInstance().getCreationTime () << updating after each clearing application data but token is null and onTokenRefresh() is not called ever


I added library into deps like:
+android_aar_prebuilt("firebase_messaging_java") {
+  deps = [
+    ":google_play_services_basement_java",
+    ":firebase_common_java",
+    ":firebase_iid_java",
+  ]
+  _lib_name = "firebase-messaging"
+  aar_path = "$firebase_path/$_lib_name/$gms_version/$_lib_name-$gms_version.aar"
+}......


android_library("chrome_java") {  deps = [    ":chrome_public_apk_manifest",    ":chrome_public_apk_template_resources",    "//base:base_java",
+  "//third_party/android_tools:firebase_messaging_java",


Added servises to AndroidManifest.xml like 
         <service  android:name="name.rocketshield.chromium.firebase.MyFirebaseMessagingService"
        android:enabled="true"
        android
:exported="false">
           
<intent-filter>
               
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
           
</intent-filter>
        </
service>
           
<!-- [END firebase_service] -->
           
<!-- [START firebase_iid_service] -->
       
<service
            android
:name="name.rocketshield.chromium.firebase.MyFirebaseInstanceIDService"
            android
:enabled="true"
        android
:exported="false">
           
<intent-filter>
               
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
           
</intent-filter>
       </
service>



Thanks for help or any response.

Peter Beverloo

unread,
Dec 23, 2016, 11:26:52 AM12/23/16
to hella...@gmail.com, Chromium-dev
It looks like you're building Chromium for Android yourself, so take a look at //components/gcm_driver/ and dependencies to see what infrastructure we already support.

InstanceIDs are part of this, and you can use them through the InstanceIDDriver which you can obtain from the InstanceIDProfileService(Factory). You may be able to extend that to your needs, for example by adding support for topics directly.

Thanks,
Peter

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+unsubscribe@chromium.org.

Jason Williams

unread,
Oct 1, 2018, 8:41:17 PM10/1/18
to Chromium-dev
Did you ever figure out how to get Firebase included in Chromium builds? There's more components that are converting from GCM to Firebase Messaging.

-J

Dan Patterson

unread,
Jun 27, 2019, 9:14:05 PM6/27/19
to Chromium-dev
Once you have your dependencies all set up you need to add the configuration strings that are generated when you create a firebase project with gradle.    There is a plugin used in gradle projects , apply plugin: 'com.google.gms.google-services'. This parses the google-services.json file from the firebase project into string resources that have specific key names and values from the json file that are used to initialize firebase.  Also when I was setting up the firebase-messaging dependency I had to add ":firebase_analytics_java". Keep in mind these dependencies are .aar files, so they contain android manifest files.  The services, receivers, meta-data, permission etc... in those manifest files need to be merged into the final chromium app manifest.  This may require pulling out the values from aar and manually putting it into the chromium manifest.  You then need to repack the aar file and add it back as a dependency.  Atleast for me Chromium complained of the ${applicationId} inside those aar files when building which is the reason for doing this.  

After the deps are working, you have the same string resources created inside the chromium project that the plugin creates from a gradle project, and the manifest values have been moved over correctly firebase should work.

Heet Parkhiya

unread,
Mar 19, 2021, 12:46:28 PM3/19/21
to Chromium-dev, patterso...@gmail.com
could you hella or anyone else tell me how they integrated the firebase a Analitycs ??
Reply all
Reply to author
Forward
0 new messages