2666
Views
50
Comments
Solved
[Firebase Mobile] Configuration guide
Forge component by David Sousa
23
Published on 26 May 2020

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.


Champion
Rank: #139
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


Rank: #849

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

Champion
Rank: #139
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


Rank: #849

Works. Thank you, David!

Hi guys,

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





Kind regards,

Nuno Verdasca

Champion
Rank: #139

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

Rank: #82051

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


Rank: #4002

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

Rank: #29289

HI Everyone. 

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


Regards,

Anahit

Rank: #2857

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/

Champion
Rank: #139

Hi Swapnil,

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

Rank: #4500

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

Rank: #83

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.


Champion
Rank: #139

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

Champion
Rank: #139

Paul,

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


Champion
Rank: #139

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.

Champion
Rank: #139

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.

Rank: #83

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

Rank: #438

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

Rank: #83

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

Rank: #83

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

Rank: #438

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 

Rank: #708

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

Rank: #83

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

Rank: #4802

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.

Champion
Rank: #139

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.
Rank: #4802

Hi David,

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

First.oml

Champion
Rank: #139

Irfan,

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

Fix the json file name and re-test.

Rank: #4802

Sure David.


Thank you

Rank: #4802

I tried as you mentioned, David.

Still I ended up with the same error.

Champion
Rank: #139

Irfan,

Please share the build log and the oml.

Thanks

Rank: #4802

Hi David.

Please find the below.

First.oml

Rank: #4802

Below is the buildlog file.

AndroidBuildLog.txt

Champion
Rank: #139

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:

Rank: #83

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

Rank: #4802

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.

Rank: #83

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

Rank: #4802

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.

Rank: #329

HI,


Me too Facing the same issue after following all the steps. attached the build log


Getting Error: In Android on 2020-11-01 at 20:42:00 - Error installing Cordova plugin: cordova-plugin-firebase': Error: ENOENT: no such file or directory, scandir '/opt/NativeBuilder/builds/8fe1e077-9dd5-4c69-9a7d-8c72e433ae74/source/platforms/android/assets/www/google-services. 

using the latest version of firebase module - Stable Version 1.0.8 (O11)  and Generating with latest MABS version on personal environment on OS11.

Under resources:

Name : google-services.zip

Target directory : firebase.com.outsystemscloud.swapnildhote.BroadcastApp

Please let me know what can be done to resolve the issue

Regards,

Swapnil

AndroidBuildLog.txt