[Firebase Mobile] Configuration guide

Forge Component
(22)
Published on 26 May by Patrícia Glória Ferreira
22 votes
Published on 26 May by Patrícia Glória Ferreira

In order to configure Firebase Mobile, follow the next steps:


1. Firebase project and configuration files

First of all, go to the Firebase console and create a project if you don’t have one already:


Add a new Firebase app for each mobile operating system your app supports. Since OutSystems allows us to build native apps for Android and iOS, let’s add both. When adding each Firebase app use the app identifier obtainable from Service Studio.

Add the Android app. Register the app in step 1 and download the configuration file in step 2. You can safely skip steps 3 and 4.

Store the Android configuration file (google-services.json) since we'll be using it shortly.


Add the iOS app. Register the app in step 1 and download the configuration file in step 2. Safely skip the remaining steps.

Again, store the iOS configuration file (GoogleService-Info.plist).



2. Setting up the configuration files

Now that we have both configuration files, let’s add them to your mobile app.

First of all, create a zip file containing both google-services.json and GoogleService-Info.plist.

Next, rename your zip folder google-services. Make sure it only contains both configuration files!



3. Adding the configuration files to your mobile app

Afterwards, add it to the Resources tab of the mobile app in Service Studio.

Ensure that the following properties are correct:

  • Name: google-services.zip
  • Deploy action: deploy to target directory
  • Target directory: concatenation of firebase. and your app identifier.

Example of target directory:

  • App identifier: com.sample.dev.FirebaseMobileSample
  • Target directory: firebase.com.sample.dev.FirebaseMobileSample


After this step you’re ready to publish your application. When you open it, it’ll be registered with Firebase!




Support to multiple environments

If you’re wondering why we have to configure the “target directory” of the configuration files to include the application identifier, that’s because we need to support having Firebase in a multiple environment scenario.

Check the following example:

  • We have 3 environments (DEV, QA and PROD)
  • As expected, our app has a different app identifier in each environment
  • Also, we'll have a Firebase project per environment, which means we'll have different configuration files per environment

After configuring the Firebase projects and setting up the configuration folders for the 3 environments, we'll add them to the app Resources tab in the lowest environment, in this case DEV.

You can now safely deploy your application with Lifetime to the upper environments.

The plugin will then pick the correct folder when the app is built and apply the right Firebase configurations to your app.


Hello.

And if I have for dev, two different app id, one for ios and one for android. 

What I should add in target directory?


Thank you in advance

Solution

Hi Camila,

In your case you can follow the next steps:

  1. define two zip folders, one for Android and other for iOS, each with the respective configuration file inside
  2. both folders should be named google-services.zip
  3. add both folders to the resources tab in Service Studio
  4. define the target directory for Android with the Android app id, like firebase.<android_app_id>
  5. define the target directory for iOS with the iOS app id, like firebase.<ios_app_id>

Regards,

David


Solution

Works. Thank you, David!

Hi guys,

Someone can help me? I do not understand the reason for this error.





Kind regards,

Nuno Verdasca

Hey Nuno,

I'm afraid that isn't a problem with the plugin. Can you try to publish the Firebase Mobile Sample espace and check if that error persists there?

Regards,

David

Hi David,

In your documentation you say

"The plugin will then pick the correct folder when the app is built and apply the right Firebase configurations to your app."

Can you please point me to where you have that code in your plugin as I wanted to see how the plugin picks up the right environment specific google zip file.

Thanks,

Mir


Hi David,

I have added Cloudnotification block in my HomeScreen and added Event Handler to that .But when i send notification from firebase console i am not receiving notification.,  let me know what i am doing wrong.


Thanks

Harish

HI Everyone. 

the plugin doesn't work for ios 13.1.1 is there any additional step needed to be done?


Regards,

Anahit

Hi David Sousa,

I followed all steps as you mentioned but I have faced issue to implement firebase plugin please check below url for more info.

https://www.outsystems.com/forums/discussion/57396/error-installing-cordova-plugin-firebase-typeerror-path-must-be-a-string/

Hi Swapnil,

If you look at the error log, no configuration file was found:

David Sousa wrote:

Hi Swapnil,

If you look at the error log, no configuration file was found:


Hi David,

Thanks for your reply.!

I did mistake in configuration firebase. Now its working fine for me.

But because of firebase google siginin functionality is not working.

without firebase its working.

Hi, we tried to use Firebase Mobile 1.0.4 on Outsystems 10 with MABS version 6.1 and change Extensibility Configuration to https://github.com/TruewindIT/cordova-plugin-firebase#1.9 . It working fine on Android but on IOS we keep getting an error:


We already contacted OS Support regarding this issue and they recommend to contact the creator of this App. Hope we can get a possitive response on this.

Thank You and Best Regards,

PJ Cezar

Hi Paul John Cezar,

Kindly post a new thread on Support of the Same plugin :)

Perhaps coming to your question the version Version 1.0.4 is compatible with OS-10.

Don't change the configuration otherwise, there's no meaning of using a standard version of this plugin.


assif_tiger wrote:

Hi Paul John Cezar,

Kindly post a new thread on Support of the Same plugin :)

Perhaps coming to your question the version Version 1.0.4 is compatible with OS-10.

Don't change the configuration otherwise, there's no meaning of using a standard version of this plugin.



If I didnt change the Extensibility Configuration I'm getting an error both IOS and Android. It seems that MABS 6.1 is compatible on that version ( https://github.com/TruewindIT/cordova-plugin-firebase#1.9 ). I will create a new thread for this I just thought going directly here will have a faster response.


Thank YOu

Hi Paul,

From what I see in your build error, you're missing the Firebase configuration file. Did you follow the configuration guide?

You can use the latest component version (1.0.7) since it's backwards compatible with OS10.

Regards

David Sousa wrote:

Hi Paul,

From what I see in your build error, you're missing the Firebase configuration file. Did you follow the configuration guide?

You can use the latest component version (1.0.7) since it's backwards compatible with OS10.

Regards

Hi Sir David,

Can you identify what file did I miss? I follow every step. I'm badly needed this one to be done by tomorrow.

1. Download IOS and Android config file.

2. zip two files, and name it google-services.zip.


3. see image below:

Paul,

Can you please share the module so that I can take a closer look at what might be the problem?


David Sousa wrote:

Paul,

Can you please share the module so that I can take a closer look at what might be the problem?


Hi Sir David,

I jsut shared the project. Just to confirm after downloading the file no other configuration will be done on Firebase Console right? 


Thank You


Paul,

I was able to generate your application on my personal environment.

Can you please confirm that your app identifier matches the one you chose on Firebase? 

On the Firebase console, after downloading the configuration files, nothing else is needed from a configuration perspective.

David Sousa wrote:

Paul,

I was able to generate your application on my personal environment.

Can you please confirm that your app identifier matches the one you chose on Firebase? 

On the Firebase console, after downloading the configuration files, nothing else is needed from a configuration perspective.


Hi Sir David,


Generated IOS and Android  successfully Sir? using Firebase Mobile 1.0.4 with MABS 6.1 on Outsystems 10 ? Yes, I just copied the App Identifier on service studio. Please see pic below.



Thank You



Paul,

Why are you using the version 1.0.4 of the component?

I generated using MABS 6.1, Outsystems 11 and the latest component version.

I'd say that the Outsystems version doesn't affect the app generation, since that process is done on MABS, but I'm not entirely sure.

I advised him on a thread with the below solution & I guess it should work.

Considering he is using OS-10 :

FirebaseComponent : 1.0.7

MABS: 6.0 or 6.1

Extensibility Configuration:  https://github.com/TruewindIT/cordova-plugin-firebase#1.9

David Sousa wrote:

Paul,

Why are you using the version 1.0.4 of the component?

I generated using MABS 6.1, Outsystems 11 and the latest component version.

I'd say that the Outsystems version doesn't affect the app generation, since that process is done on MABS, but I'm not entirely sure.

Hi Sir David,

I'm using Outsystem 10 with MABS 6.1. That's the recommendation of Outsystems Support to use version 1.0.4 since 1.0.7 is version for Outsystems 11 so we trying to use the lower version instead, but it prompt same error.



Thank You





assif_tiger wrote:

I advised him on a thread with the below solution & I guess it should work.

Considering he is using OS-10 :

FirebaseComponent : 1.0.7

MABS: 6.0 or 6.1

Extensibility Configuration:  https://github.com/TruewindIT/cordova-plugin-firebase#1.9


Hi,


for 

FirebaseComponent : 1.0.7

MABS: 6.0 or 6.1

Extensibility Configuration:  https://github.com/TruewindIT/cordova-plugin-firebase#1.9 


It prompt error: "An unexpected error has occurred while generating your application. Please try again. If the problem persists, contact OutSystems Support.


As I said earlier, we already contact Outsystems Support and they recommend to use the lower version (1.0.4) instead of (1.0.7) but it prompt same error.



Thank You

Hi David,

When using Firebase Mobile plugin with Google Login plugin in application, not able to generate application build. Although its working for Android. Error which I am getting is only  "Error: An unexpected error has occurred while generating your application. Please try again. If the problem persists, contact OutSystems Support."

If we build application only using Firebase Mobile plugin or Google Login plugin then application build successfully. But when use both plugins its get failed.

Please suggest.

Thanks and Regards

Vikas

Hi Vikas,

Make sure to use the latest version of Google Login Plugin.

There's a conflict with older version of Google Login Plugin with Firebase.


- Assif

If you want to know the issue then refer my deatiled post on this thread:


https://www.outsystems.com/forums/discussion/57672/incompatibilityconflicts-between-firebase-plugin-and-gogle-login-plugin/

I had suggested 2 approach to fix.

But now thankfully the GoogleLogin Plugin owner changed the source repo & things fiexd now.

You can ref the latest version of it to resolve.


Hope it help,

Assif

Hi Assif,

I used latest version of Google login plugin, with repo : "url": "https://github.com/andregrillo/cordova-plugin-googleplus.git",

Also using firebase mobile plugin in application.

But while build application getting below error in iOS build.

In iOS on 2020-06-12 at 09:33:19 - An unexpected error has occurred while generating your application. Please try again. If the problem persists, contact OutSystems Support.

There is no error details. Also if we use both plugin separately then its working. But failed when use both the plugins.

Please suggest.

Thank you,

Regards

Vikas 

Hi Vikas,


The Firebase Plugin and Google login uses some common code or library so many time while building the apps they conflicts each other and  to solve that you have to remove that particular library from either of the plugin.


For Android you can follow assif answer, Although I did not have any issue with latest plugins in android


For iOS, I found that there is a common library called 'GoogleUtilities' used in both plugins so in that case I need to remove this from anyone of the library. So I decided to remove it from Google plugin and for that I have created a GIT FORK of Cordova Google plugin and removed the dependent library from config.xml. Then I just replace the URL of the Cordova plugin in my app and build it, after that it it working fine.

Please check in the below fork link if you want to check the solution

https://github.com/pjain168/cordova-plugin-googleplus


Hope this helps.


Thanks

Pankaj


Hi,

I have configured 'Firebase Mobile' plugin in my mobile application, I need to navigate to another screen on clicking the received push notification sent using firebase REST API from backend. But when I am sending the screen name in "click_action" key in the request body JSON from API,I am receiving the notification but it is not opening the application on clicking the notification received.

I am using POST request to "https://fcm.googleapis.com/fcm/send" to send a push notification from backend.

Request body JSON used is:

{

    "to":"<device-registration-id>",

    "notification": {

      "title": "title",

      "body": "body",

      "sound": "default",

      "content_available": true,

      "click_action": "ScreenName"

      },


   "data": {

       "quoteid": "",

       "dl": ""

    }

}

I have been trying to solve this issue from a long time but unable to, hope I will get some help.

Thanks in advance.

Regards,

Sushma

Hi Sushma,

Kind advice, do create a new thread in order to get a quick reply for the same.

Coming to your issue, I am using the Deeplink but with firebase actions provided & it is working like a charm.

If you see your request structure & the one used by FirebaseMiddleware is different:

{

    "to":"",

    "registration_ids":[""],

    "condition":"",

    "data":[{"Key":"","Value":""}],

    "notification": {

        "title":"",

        "body":""

    }

}


The deep link is passed as a key-value under data array.


Pass something like this in your request ;

  "data": { "client_action": "your_screen-name-here"  }



I would say - post a new thread in the support section of the same plugin with request-headers & body so that folks can get a clear picture.



- Assif

assif_tiger wrote:

Hi Sushma,

Kind advice, do create a new thread in order to get a quick reply for the same.

Coming to your issue, I am using the Deeplink but with firebase actions provided & it is working like a charm.

If you see your request structure & the one used by FirebaseMiddleware is different:

{

    "to":"",

    "registration_ids":[""],

    "condition":"",

    "data":[{"Key":"","Value":""}],

    "notification": {

        "title":"",

        "body":""

    }

}


The deep link is passed as a key-value under data array.


Pass something like this in your request ;

  "data": { "client_action": "your_screen-name-here"  }



I would say - post a new thread in the support section of the same plugin with request-headers & body so that folks can get a clear picture.



- Assif

 

Inside that array, can you show me a sample of the exact line of parameter you had sent? i'm still finding out about Deeplinking from push notification.

Do I need to modify the FirebaseMiddleware module first?

assif_tiger wrote:

The deep link is passed as a key-value under data array.


Pass something like this in your request ;

  "data": { "client_action": "your_screen-name-here"  }



I would say - post a new thread in the support section of the same plugin with request-headers & body so that folks can get a clear picture.



- Assif

 

Can we put an URL into that array value? And anyway, I think it's "click_action" not "client_action".

after implementing 3. Adding the configuration files to your mobile app 

how can we check the analytics of my mobile app?

is there a way to check ? or do i need to add or follow any other steps?


Thank you.

Irfan,

After step 3 you only need to generate the app and install it in a mobile device.

There are multiple ways to check if Firebase SDK is running:

  • using Firebase's stream view
  • checking the device's logs for Firebase messages
  • using the application (so that some events are sent to Firebase), waiting for some time (~ 1 day) and checking the Firebase console for those events.

Hi David,

I am getting below error while generating the app, please help me to resolve this.

Irfan,

Take a look at the files inside your google-services zip.

Fix the json file name and re-test.

Sure David.


Thank you

I tried as you mentioned, David.

Still I ended up with the same error.

Irfan,

Please share the build log and the oml.

Thanks

Hi David.

Please find the below.

Below is the buildlog file.

Irfan,

As I can see in the build log, the app identifier is com.outsystemscloud.mahammadirfan.First.

In the guide's section 3 you can see that the target directory of the google services folder needs to contain the app identifier:

Irfan,
yep as David pointed out, from what I see is you are missing the right specification for the Resource file.

Considering your :

App Identifier: com.outsystemscloud.mahammadirfan.First
TargetDirectory : firebase.com.outsystemscloud.mahammadirfan.First



Kind request :
Please create a new thread on plugin support - if you have a question :)
It helps the next dev to find the right question & answer.


Hope it helps,
Assif

Error installing Cordova plugin: cordova-plugin-firebase. Error in plugin.xml file: the specified pod was not found in the CocoaPods repository

Hi Team

I am getting above error while generating the IOS app.

However it is working fine for Android.

The Extensibility configuration for the Firebase Mobile Plugin is as follows.

  "plugin":

    {

        "url": "https://github.com/TruewindIT/cordova-plugin-firebase-only-analytics-notifications#1.0"

    }


Thank you.

Hi Irfan,

Please post a new thread for same. This will help you n other folks to quickly respond.

Perhaps coming to the issue..do mention the plugin version and MABS version you are using.

I am using the latest version with MABS 6.1 & it's working like a charm.


Also mention if you are using any other plugin in mobile app as well.


Thanks,

Assif

Hi Assif,

Thank you for prompt response.

I created the separate thread for the above issue in below link.

https://www.outsystems.com/forums/discussion/64886/firebase-ios-generating-app-error/#Post255462

I mentioned all details in that post.

I am using other plugins like FaceId, Android back button disable.

Please reply me in above link.


Thank you.