locked
Options to Properly Add FireBase to My Xamarin Forms Project RRS feed

  • Question

  • User204212 posted

    Hi guys,

    I need to use firebase Cloud Messaging in my project, decide to follow all the official microsoft guidelines but I have had some bugs trying to add dependencies.

    First, when adding the json file generated by Firebase (google-services.json) in the Android project, I don't see the option to add the resource as *GoogleServiceJson *(Step: In Properties> Advanced> Build Action, select GoogleServicesJson.)

    Second, when I try to add the NuGetPackage Xamarin.Firebase.Messaging in the android project it throws me the error the $ (TargetFrameworkVersion) for PGTApp.Android (v8.1) is less than the minimum required $ (TargetFrameworkVersion) for Xamarin.Forms ( 9.0). I am clear where I have to change for this to be fixed, but it remains the same without being able to be added.

    Finally, I have updated to the latest version of xamarin forms but still unable to enable Firebase in my project.

    Some aspects of my project: 1. Xamarin Forms version: 4.6.0.800 2. .Net Standard version: 2.0 3. Xamarin.Firebase.Messaging version: 17.1740.1 (not installed) 4. Sdk version minimum Api16 and maximum Api29. For the Android project.

    My main question is what other options can I have to use Firebase in my project or how can I solve this problem?

    Thank you very much, Greetings from Panama

    Tuesday, May 19, 2020 2:33 AM

Answers

  • User371688 posted

    First, when adding the json file generated by Firebase (google-services.json) in the Android project, I don't see the option to add the resource as *GoogleServiceJson *

    For the first question, you can try to install nuget Xamarin.GooglePlayServices.Base , then restart visual studio and rebuilt your app.

    Second, when I try to add the NuGetPackage Xamarin.Firebase.Messaging in the android project it throws me the error the $ (TargetFrameworkVersion) for PGTApp.Android (v8.1) is less than the minimum required $ (TargetFrameworkVersion) for Xamarin.Forms ( 9.0).

    For the second question, we need to make sure the Minimum Android Version less than or equal to the Target Android version.

    Meanwhile, the Target FrameWork is usually the same with the Target Android version.

    Note: you can check this tutorial Firebase Push Notification in Xamarin Forms - Xamarin Forms Tutorial , it should be helpful for you.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Tuesday, May 19, 2020 6:22 AM
  • User371688 posted

    Hi, juanzeta33, I suggested that you install nugets Xamarin.GooglePlayServices.Base and Xamarin.Firebase.Messaging for your xamrin android project, not for the shared project. You can follow the tutorial I posted above to finish your app. If you encounter any problems, please let me know and I will try my best to help you. :)

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Wednesday, May 20, 2020 1:40 AM

All replies

  • User371688 posted

    First, when adding the json file generated by Firebase (google-services.json) in the Android project, I don't see the option to add the resource as *GoogleServiceJson *

    For the first question, you can try to install nuget Xamarin.GooglePlayServices.Base , then restart visual studio and rebuilt your app.

    Second, when I try to add the NuGetPackage Xamarin.Firebase.Messaging in the android project it throws me the error the $ (TargetFrameworkVersion) for PGTApp.Android (v8.1) is less than the minimum required $ (TargetFrameworkVersion) for Xamarin.Forms ( 9.0).

    For the second question, we need to make sure the Minimum Android Version less than or equal to the Target Android version.

    Meanwhile, the Target FrameWork is usually the same with the Target Android version.

    Note: you can check this tutorial Firebase Push Notification in Xamarin Forms - Xamarin Forms Tutorial , it should be helpful for you.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Tuesday, May 19, 2020 6:22 AM
  • User204212 posted

    Hi @jezh ,

    For the first question, you can try to install nuget Xamarin.GooglePlayServices.Base , then restart visual studio and rebuilt your app.

    I have already tried this and the same thing happened when trying to install the Xamarin.Firebase.Messaging package. What I'm trying to do is install that package just for the shared project.

    For the second question, we need to make sure the Minimum Android Version less than or equal to the Target Android version.

    This is already set the way you indicate.

    Note: you can check this tutorial Firebase Push Notification in Xamarin Forms - Xamarin Forms Tutorial , it should be helpful for you.

    I am going to watch and follow the tutorial, if I get a good result I will notify you.

    Thanks you so much!

    Tuesday, May 19, 2020 4:26 PM
  • User371688 posted

    Hi, juanzeta33, I suggested that you install nugets Xamarin.GooglePlayServices.Base and Xamarin.Firebase.Messaging for your xamrin android project, not for the shared project. You can follow the tutorial I posted above to finish your app. If you encounter any problems, please let me know and I will try my best to help you. :)

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Wednesday, May 20, 2020 1:40 AM
  • User204212 posted

    Hello @jezh ,

    Until now I was able to see and follow the tutorial and let me tell you that everything has been installed without errors, thanks. I have managed to perform all the configuration with the firebase and the xamarin forms, but I still cannot see the notification on the device or retrieve the token of my app to test directly.

    You have solved my question, however I would like if you can help me a little more to show the notification? I will send you a direct message.

    Cheers,

    Thursday, May 21, 2020 12:02 AM