Firebase For Macos Application

Posted on by
Firebase For Macos Application Rating: 4,9/5 1311 reviews

Sep 27, 2019  Firebase is a great backend solution for anyone that wants to use authentication, databases, cloud functions, ads and countless other features within an app. Luckily for us, Flutter has official support for Firebase with the FlutterFire set of libraries. As we’re dealing with iOS and Android platform(s), we’ll have to go through the setup process for both. Firebase 2.5.1 continues to work with OS X. Here's the legacy Getting Started Guide which has a link to the download and also QuickStart for installing via CocoaPods. See my post in the link @FrankvanPuffelen provided above (3rd msg down in the link) for a sample pod file config. Dec 28, 2019  Firebase will take some time to ready your application. Once done, click on the Continue button to open up the Firebase Project Overview Page. Configure an iOS Application. In your Firebase Project Overview Page, launch the setup wizard for iOS. Nov 27, 2019  Configure the Android application for notifications. Complete the following steps to configure the Android application to receive and process notifications: Configure the Android Package name to match the package name in the Firebase console. Install the following NuGet packages to interact with Google Play, Firebase and Azure Notification Hubs.

Related

Using Pug and Sass in Flutter with flutter-view Tutorial

Tutorial

While this tutorial has content that we believe is of great benefit to our community, we have not yet tested or edited it to ensure you have an error-free learning experience. It's on our list, and we're working on it! You can help us out by using the 'report an issue' button at the bottom of the tutorial.

Firebase is a great backend solution for anyone that wants to use authentication, databases, cloud functions, ads and countless other features within an app. Luckily for us, Flutter has official support for Firebase with the FlutterFire set of libraries.

As we’re dealing with iOS and Android platform(s), we’ll have to go through the setup process for both. Let’s start by ensuring we’ve got a Firebase project created over at https://console.firebase.google.com.

Creating a New Flutter Project

In order to follow along with the setup we’ll be creating an example Flutter app. Assuming you already have the Flutter and Dart SDKs installed, run the following in your terminal:

Now that we’ve got a Flutter project up and running, we can add Firebase.

Creating a New Firebase Project

From within the Firebase dashboard, select the “Create new project” button and give it a name:

Firebase for macos application mac

Next up, we’re given the option to enable Google Analytics. It isn’t directly necessary for what we’re trying to do, so do whatever feels right for your use-case here.

Assuming that we’re using Google Analytics, we’ll need to review and accept the terms and conditions prior to project creation.

After a relatively painless setup process, we should now be navigated to the dashboard for our project.

Adding Android support

Step 1: Register app

In order to add Android support to our Flutter application, select the Android logo from the dashboard. This brings us to the following screen:

The most important thing here is to match up the Android package name that you choose here with the one inside of our application. The structure of this is done like so: com.example.app.

Once you’ve decided on a name, head over to android/app/build.gradle and update the applicationId to match this:

You can skip the nickname and debug signing keys at this stage. Select “Register app” to continue.

Step 2: Download config file

The next step is to add the Firebase configuration file into our Flutter project. This is important as it contains the API keys and other critical information for Firebase to use.

Select “Download google-services.json” from this page.

Once you’ve got this, take the file and place it inside of the android/app directory within the Flutter project.

Step 3: Adding the Firebase SDK

We’ll now need to update our Gradle configuration to include the Google Services plugin. Open up android/build.gradle and modify it to include the following:

Finally, update the app level file at android/app/build.gradle to include the following:

With this update, we’re essentially applying the Google Services plugin as well as looking at how other Flutter Firebase plugins can be activated such as Analytics.

From here, run your application on an Android device or simulator. If everything has worked correctly, you should get the following message in the dashboard:

Next up, let’s add iOS support!

Adding iOS support

In order to add Firebase support for iOS, we have to follow a similar set of instructions.

Head back over to the dashboard and select Add app and then iOS icon to be navigated to the setup process.

Step 1: Register an app

Once again, we’ll need to add an iOS Bundle ID which I’m keeping the same as Android for consistency:

You’ll then need to make sure this matches up by opening the iOS project up in Xcode at ios/Runner/Runner.xcodeproj and changing the Bundle identifier under General:

Click “Register app” to move to the next screen.

Step 2: Download config file

In this step we’ll need to download the configuration file and add this to our Xcode project.

Download GoogleService-Info.plist and drag this into the root of your Xcode project within Runner:

It’s important that you don’t simply drag this into the folder without going through Xcode, as this will not work.

That’s it! You’ll also be happy to know that we can skip the rest of the steps from here on out.

Conclusion

We’ve now learned how to set up and ready our Flutter applications to be used with Firebase in the near future.

In future articles we’ll look at how to use Firebase features such as Cloud Firestore, Authentication, Analytics, and more with Flutter.

Firebase is a mobile app development platform developed by Firebase, Inc. in 2011, and then Acquired by Google in 2014. It provides various features such as Cloud Storage, Authentication and an ML kit, which are essential to developing modern mobile applications.

Additionally, it provides services such as Performance Monitoring, Crashlytics and Google Analytics to help you improve the quality of your applications.

In this tutorial I am going to show you how to connect your Flutter iOS application to the Firebase Platform on a Mac Computer, so you can utilize the powerful services provided by the firebase API in your future endeavors…

1. Readying a Gmail Account and a Flutter Project

In order to utilize services from Firebase and Google Cloud Platform, you will need a Google Account. If you do not have one, simply following the page instructions here to register for one.

This tutorial is going to show you how to connect your existing Flutter application to the Firebase platform. If you are interested in how to create your first Flutter application, I have a tutorial on How to create your first iOS Flutter app on MacOS. By the end of that tutorial, you should have a hello_world application ready in the simulator and understand how to alter the application by modifying the main.dart file.

2. Creating a Firebase Project

In order to integrate your Flutter application with the Firebase Platform, first you have to create a Firebase Project. And here are the steps.

1. Go to the Firebase Console.

2. Click on the big Add project button.

3. Enter your Project name.

  • I used hello-world for this example. Firebase automatically appends a unique ID to your project name — for example, the project I created ended up with the name hello-world-f2206.

4. You can pick a Cloud Firestore Location.

  • I left it as nam5 (us-central) because I live in Los Angeles, but the Cloud Functions are not available on us-west2, and the traffic in between will create additional charges. You can find more about service availabilities and server locations here.

5. Accept the Terms and Conditions.

5. Once you are done, scroll to the bottom and click Create Project.

  • See 3.1 Switching to Administrator Account in the appendix at the end of this article if you encountered an error message asking for an administrator account.

Firebase will take some time to ready your application. Once done, click on the Continue button to open up the Firebase Project Overview Page.

4. Configure an iOS Application

1. In your Firebase Project Overview Page, launch the setup wizard for iOS.

2. Inside the setup wizard, put in the iOS bundle ID. The Register app button should then light up, click on it.

Firebase For Macos Application Windows 10

  • A guide on how to find the iOS bundle ID can be found the below in section 4.1 Finding iOS Project root folder & Acquiring Bundle ID of the appendix.

3. Download the GoogleService-Info.plist configuration file and put it into the iOS Project root folder, then click Next.

  • A guide on how to find the iOS bundle ID can be found below in section 4.1 Finding iOS Project root folder & Acquiring Bundle ID of the appendix.

4. Follow the instructions to add the Firebase SDK, then click Next.

  • A detailed guide on how to install CocoaPods and Firebase SDK can be found below in section 4.2 Installing CocoaPods and Firebase SDK.

5. Modify the code inside the main AppDelegate as instructed by the setup wizard then click Next. For this example, I used Objective-C, and therefore replaced the contents inside AppDelegate.m with the following code.

6. Get back to the root folder and run your app, after a while you should see the setup wizard showing that your app is added to Firebase. Click Continue to the Console to finish the setup.

Congratulations! You have successful added Firebase to your Flutter application. Despite the fact that having both Firebase and Flutter from Google is supper cool, it is actually a good Software Engineering practice to always have a plan B, as well as plan C, D,E, F, and G. In the future I will write another guide on an example application utilizing Firebase, and more on Flutter.

Have fun coding!!!

Appendices:

3.1 Switching to Administrator Account

If you ran into the following message, it means that you need to contact the organization of your Gmail account to grant you access to Google Developers Console.

4.1 Finding iOS Project root folder & Acquiring Bundle ID

1. Launch Xcode from the Launchpad.

2. Select “Open another project…” at the bottom of the prompt screen.

3. Navigate to your Flutter project folder, open the “ios” folder and select “Runner.xcodeproj”. This should automatically open up the project in Xcode.

4. Select the Runner project on the left, you should now see the Bundle Identifier under Identity.

4.2 Installing CocoaPods and Firebase SDK

Firebase Mac

In case the instructions inside the setup wizard did not work out, you will have to remove the existing Podfile in order to reinstall them correctly.

1. CocoaPods is built with Ruby and is installable with the default Ruby available on MacOS. Use the following commands to install it.

2. Initialize the Podfile with the following command.

Firebase For Macos

3. Then, add the following code to the initialized Podfile.

4. Once done, save the changes made to the Podfile, and install the Firebase SDK with the following command.

5. After the installation, you will likely have to configure the .xcconfig files. First you will have to copy the files from the Pods/Target Support Files/Pods-Runner folder to Flutter folder.

6. Then you will have to include them into the Debug.xcconfig and Release.xcconfig files inside the Flutter folder.

Macos

Firebase For Macos Application Download

In Debug.xcconfig:

Firebase For Macos Application Mac

In Release.xcconfig: