Select a device from the Device Selector area. For details, see Quickly switching between Flutter devices. If no device is available and you want to use a device simulator, click No Devices and launch a simulator. Warning: You may not see Start iOS Simulator option when you click No Devices in VS Code. If you are on Mac then you may have to run. If an AVD already exists, you can start the emulator directly from the device selector in Android Studio, as shown in the next step.(For the iOS Simulator, if it is not already running, launch the simulator on your development machine by selecting Flutter Device Selection - Open iOS Simulator.) 2. Start your Flutter app: Look for the Flutter.
In this codelab, you'll build a login page using several of MDC Flutter's components.
This codelab is the first of four codelabs that will guide you through building an app called Shrine, an e-commerce app that sells clothing and home goods. It will demonstrate how you can customize components to reflect any brand or style using MDC-Flutter.
In this codelab, you'll build a login page for Shrine that contains:
- An image of Shrine's logo
- The name of the app (Shrine)
- Two text fields, one for entering a username and the other for a password
- Two buttons
Android | iOS |
By the end of MDC-104, you'll build an app that looks like this: | The related codelabs can be found at: |
How would you rate your level of experience with Flutter development?
For more information about Flutter installation, see Get Started: Install. To set up an editor, see Get Started: Set up an editor. When installing an Android emulator, feel free to use the default options such as a Pixel 3 phone with the latest System Image. It's recommended but not required to enable VM acceleration. After the above 4 steps have been completed, you can return to the codelab. To complete this codelab, you only need to install Flutter for one platform (Android or iOS).
flutter upgrade to ensure that the SDK is at the latest state.Running flutter upgrade
will automatically run flutter doctor.
If this a fresh Flutter install and no upgrade was necessary, then run flutter doctor
manually. It will report if there are any dependencies you need to install to complete the setup. Feel free to ignore the check marks that are not relevant for you (for example Xcode if you do not intend to develop for iOS).material-components-flutter-codelabs-101-starter/mdc_100_series directory.The right branch
Codelabs MDC-101 through 104 consecutively build upon each other. So when you finish the code for 101, it becomes the starter code for 102! The code is divided across different branches, and you can list them all with this command:git branch --list
To see the completed code, checkout the 102-starter_and_101-complete
branch.Tip: Make sure you have the plugins installed for Flutter and Dart.1. Open Android Studio.2. If you see the welcome screen, click Open an existing Android Studio project. 3. Navigate to the material-components-flutter-codelabs/mdc_100_series
directory and click Open. The project should open. You can ignore any errors you see in Dart Analysis until you've built the project once. 4. If prompted: - Install any platform and plugin updates or FlutterRunConfigurationType.
- If the Dart or Flutter SDK is not configured, set the Flutter SDK path for the Flutter plugin.
- Configure Android frameworks.
- Click on 'Get dependencies' or 'Run ‘flutter packages get'.
Then restart Android Studio. 1. Select the device or emulator.If the Android emulator is not already running, select Tools -> Android -> AVD Manager to create a virtual device and start the emulator. If an AVD already exists, you can start the emulator directly from the device selector in Android Studio, as shown in the next step.(For the iOS Simulator, if it is not already running, launch the simulator on your development machine by selecting Flutter Device Selection -> Open iOS Simulator.) 2. Start your Flutter app:- Look for the Flutter Device Selection dropdown menu at the top of your editor screen, and select the device (for example, iPhone SE or Android SDK built for <version>).
- Press the Play icon ().
If you were unable to run the app successfully, stop and troubleshoot your developer environment. Try navigating to material-components-flutter-codelabs
or if you downloaded the .zip file material-components-flutter-codelabs-.
) in the terminal and running flutter create mdc_100_series
.Success! The starter code for Shrine's login page should be running in your simulator. You should see the Shrine logo and the name 'Shrine' just below it.Android iOS
Let's look at the code.login.dart
Paint 3d pressure sensitivity. Open up login.dart
. It should contain this:Notice that it contains an import
statement and two new classes:- The
import
statement brings Material Components into this file. - The
LoginPage
class represents the entire page displayed in the simulator. - The
_LoginPageState
class's build()
function controls how all the widgets in our UI are created.
For more of the basics of the Flutter UI and what widgets are, you can take a Tour of the Flutter Widget Framework or do the codelab Write Your First Flutter App, part 1.To begin, we'll add two text fields to our login page, where users enter their username and password. We'll use the TextField widget, which displays a floating label and activates a touch ripple.Material's text fields have been greatly enhanced to improve brand flexibility, with improvements backed by extensive user experience (UX) research for better usability and visual design.Learn more about the new text fields in their article of the Material Guidelines.This page is structured primarily with a ListView, which arranges its children in a scrollable column. Let's place text fields at the bottom.SizedBox(height: 120.0).The text fields each have a decoration:
field that takes an InputDecoration widget. The filled:
field means the background of the text field is lightly filled in to help people recognize the tap or touch target area of the text field. The second text field's obscureText: true
value automatically replaces the input that the user types with bullets, which is appropriate for passwords.Save your project (with the keystroke: command + s) which performs a hot reload.You should now see a page with two text fields for Username and Password! Check out the floating label animation:Android iOS
If the app doesn't update, click the 'Play' button again, or click 'Stop' followed by 'Play.'TextField features include:- The TextField widget's look can be easily changed. For the decoration field, specify an InputDecoration value.
- The MDC text field displays touch feedback (called the MDC ripple or 'ink') by default.
- The FormField is a similar widget that has special features for embedding fields in Forms.
Next, we'll add two buttons to our login page: 'Cancel' and 'Next.' We'll use two kinds of MDC button widgets: the FlatButton (called the 'Text Button' in the Material Guidelines) and the RaisedButton (referred to as the 'Contained Button').Learn more about button hierarchy in the Buttons article of the Material Guidelines.ButtonBar to the ListView
's children:The ButtonBar arranges its children in a row.Flutter Test Setup
Then add two buttons to the ButtonBar's list of children
:For more information on buttons and their interactions, see Adding Interactivity to Your App.Save your project. Under the last text field, you should see two buttons appear:
Android iOS
The ButtonBar handles the layout work for you. It positions the buttons horizontally, so they appear next to one another, according to the padding in the current ButtonTheme. (You'll learn more about that in codelab MDC-103.)Touching a button initiates an ink ripple animation, without causing anything else to happen. Let's add functionality into the anonymous onPressed:
functions, so that the cancel button clears the text fields, and the next button dismisses the screen:TextEditingControllers to control their text.Right under the _LoginPageState
class's declaration, add the controllers as final
variables.On the first text field's controller:
field, set the _usernameController
:On the second text field's controller:
field, now set the _passwordController
:onPressed:
function:Save your project. Now when you type something into the text fields, hitting cancel clears each field again.This login form is in good shape! Let's advance our users to the rest of the Shrine app.app.dart of our app, calling initialRoute: '/login',
adds the login screen to the Navigator, on top of what is passed in home:
.Learn more about routes and navigation in Navigation Basics.In the RaisedButton's onPressed:
function, pop the most recent route from the Navigator:Lastly, open up home.dart
and set resizeToAvoidBottomInset
to false
in the Scaffold
:Doing this ensures that the keyboard's appearance does not alter the size of the home page or its widgets.That's it! Save the project. Go ahead and click 'Next.'You did it!Android iOS
This screen is the starting point for our next codelab, which you'll work on in MDC-102.About Buttons:- In addition to FlatButton and RaisedButton, there's OutlineButton, FloatingActionButton IconButton, and more.
- Browse buttons and their documentation in the MDC Widgets catalog.
We added text fields and buttons and hardly had to consider layout code. Material Components for Flutter come with a lot of style and can be placed on screen almost effortlessly.The completed MDC-101 app is available in the 102-starter_and_101-complete
branch.You can test your version of the app against the app in that branch.Alternatively, head over to MDC-102: Material Design Structure and Layout to learn about the components covered in MDC-102 for Flutter.I was able to complete this codelab with a reasonable amount of time and effort
Strongly agree Agree Neutral Disagree Strongly disagree I would like to continue using Material Components in the future
Strongly agree Agree Neutral Disagree Strongly disagree Important: If you want to see a detailed video guide on how to add push Flutter push notifications to Flutter apps, check out my complete Flutter course. There, you not only learn Flutter from scratch but you also find a complete section where we build a Chat App that also uses Push Notifications to deliver messages!Push Notifications are a common feature in mobile apps, yet adding them can be tricky. Or at least, it involves a couple of steps that you have to go through.This guide provides you with all the steps for Android and iOS apps built with Flutter. # How Do Push Notifications Work?
As you’ll see below, it takes a couple of steps to add push notifications to an app. The reason for that mainly is security - after all you definitely don’t want anyone to send out push messages to your apps’ users.Before we actually write any code, it’s important to understand how push notifications work. You can skip this and jump right ahead to the Android or iOS parts but I strongly recommend that you pick up these important basics first!Here’s how Push Notifications are delivered to your app / the users of your app:Let me explain this image.First of all, you have to understand that you have two “ends”: The frontend (your app, running on your users’ devices) and the backend (a server you own which does the “behind the scenes” work). For more information on that, check out our Frontend vs Backend article.We need both ends because you are most likely not just deliver a nice app UI to your users. Instead, your app probably should be able to offer certain features to your users.For example:- Authentication (Signup & Login)
- Storing data in a database (e.g. chat messages)
- Storing uploaded images (e.g. user photos)
These are the kind of things your backend server does. Your Flutter app communicates with that server - all these features are by the way also covered in my Flutter course.Back to the image.The natural thing would be that you simply push a notification from your backend to the frontend and that then shows that notification on the user’s device, even if your app is in the background at the moment.But it doesn’t work like that.You absolutely can communicate like this with your app if it’s in the foreground. But if it’s in the background (i.e. currently not running), you need help from the device’s operating system (iOS or Android) because it’s the operating system that shows the notification in the end. You can’t directly communicate with your app, if it’s not running at the moment.Both Android and iOS don’t work such that they expose a simple API to which you can send a request, which then in turn what lead to a notification being shown on the device.Why?Because that would be highly insecure!Anyone could be pushing to any device - and we definitely don’t want that!Therefore, as a developer, you have to register your app with Google and Apple and let them know that you plan on having push notifications as part of your app. You’ll then get a unique key which you can use to send a “please deliver this message” request to Google’s or Apple’s push services and those services then go ahead and deliver the message to the devices (where the message is shown then).So long story short - we need to do the following things in order to be able to deliver push notifications:- Register our app with Google and Apple and let them know that we want to send push notifications
- Use the key / certificate that we get for sending messages
- Add code to our app to define what should happen if a user interacts with a received push notification
# Adding Push Notifications to Android Flutter Apps
Let’s add push notifications to an Android Flutter app.Since Android is Google’s mobile operating system, we need to use Google’s push notification service to deliver the message (why? see above). This service is called FCM (Firebase Cloud Messaging). Firebase simply is a product offered by Google. Firebase offers more than just push notifications but the push service is part of it.First of all, you need to sign up with Firebase and log into the Firebase Console. Run ipa on pc.There, you then need to add a new Android app.Simply follow the assistant and download the generated google-services.json
file to your Flutter project. There, store it in the android/app
folder.Next, edit your android/build.gradle
file and add the following line to dependencies
:Also edit the android/app/build.gradle
file to add this line of code at the bottom of the file:That’s it, this generally prepares your Android app to be able to receive (but not yet handle) push notifications.The google-services.json
basically is that unique key I mentioned earlier. It contains unique identification data which tells Android that your app is registered to receive push notifications.Keep in mind that we did register it in the Firebase console. Firebase is a Google service and therefore Google is now aware of your app.Of course just adding the google-services.json
file to your project is not enough - it’s not going to be parsed and interepreted by your app automatically.Instead, we now need to add a new Flutter library to our project: The Firebase Messaging package.To install it, add the following entry to your pubspec.yaml
file:(the version can differ, find the latest version here)Thereafter, your IDE either picks it up automatically and installs it or you need to runNow we need to add some code to our Flutter app.At some point, we need to initialize the messaging package and also ask the user for permission. This could be done in the main.dart
file but you can do it anywhere (e.g. you could also do it on some screen that shows up after authentication).Once all of that is done, you can build your app and test it on an emulator or a real device.Thereafter, you can try sending a message via the Firebase web push console.Go to “Cloud Messaging” in your Firebase project console (you find it under “Grow”) and click on “Send your first message”.What is latest ios for macbook pro. Simply enter a title and a notification text and click on “Next”.In the “Target” part, simply choose “App” and then select your registered Android app in the dropdown.Click “Next” again and keep “Now” Go player pc. as a scheduled time.Click “Next” on last time (you don’t need to add any data on that final screen) and select “Review” thereafter.Once you did all of that, you can click “Publish” and after a few seconds, the message should show up on your device.Important: You can test Android push notifications both on an emulator as well as a real device. Your Flutter app of course needs to be installed on that device.At the moment, we got no control over what happens when a user reacts to a push notification (e.g. when the notification gets clicked). We’ll work on this in the later, after we added iOS push notifications. Of course you can jump right ahead if you don’t plan on supporting iOS. # Adding Push Notifications to iOS Flutter Apps
I strongly recommend that you go through the Adding Push Notifications to Android Apps part first, since that knowledge will help a lot in this part as well.Because there’s one really cool thing: Even though we have to use “APNs” for push notifications that should be delivered to iOS devices, we can continue using “FCM” (the service we needed for Android).Why?Because “FCM” supports both Android and iOS!For Android, it simply sends the messages itself, for iOS, it basically forwards your message to “APNs”. So you can use one service for both and that of course helps a lot!We still need to let Apple know about our intents though and we therefore still need to go through a couple of iOS-specific steps. But we will be using the “FCM” and also the Firebase Messaging Flutter package we used before.So first of all, you should go back to your Firebase web console and add your iOS app as well.For that, on the starting page of the console, click on “Add app” and then select the iOS icon.Go through the wizard (only until “Download config file” though) and download the GoogleService-Info.plist
file. Open your ios/Runner.xcworkspace
file with XCode and then add the GoogleService-Info.plist
file to the project.Skip the rest of the wizard (i.e. don’t go through the “Add Firebase SDK” step and the following steps).We now need to let iOS know about the fact that our apps wants to use push notifications. For that, select “Runner” in XCode and turn on “Push Notifications” and “Background Modes” in the “Signing & Capabilities” tab.Thereafter, under “Background Modes”, check “Remote notifications” and “Background fetch”. https://bestffiles158.weebly.com/canvas-tech-zachary-mac-os.html.We’re almost there, just a few steps left!As mentioned before, “FCM” is going to forward our to-be-delivered messages to “APNs”. Hence we also need to register our app with “APNs”. Do that as described here. Skip the “Create the Provisioning Profile” step!As part of the previous step, you’ll get an “APNs” authentication key (a file you had to download in the last step).This key file now needs to be uploaded to “FCM” so that this service is able to “talk to APNs”. Upload it as described here.And with that, we’re done!Make sure you added the Firebase messaging package to your Flutter app (also see the Android part of this article for more details).Last but not least, just as with Android, we need to add some Flutter code to be prepared to receive messages (and to ask for permission). If you already followed the Android instructions from above, you already have the below code snippet:With all of that done, you can save everything and re-build your Flutter app to test this.Important: Unlike for Android, you need a real iOS device to test iOS push notifications! You can’t test those on a simulator!We can test push notifications with the same steps as for Android:Go to “Cloud Messaging” in your Firebase project console (you find it under “Grow”) and click on “Send your first message”.Simply enter a title and a notification text and click on “Next”.In the “Target” part, simply choose “App” and then select your registered iOS app in the dropdown.Click “Next” again and keep “Now” as a scheduled time.Click “Next” on last time (you don’t need to add any data on that final screen) and select “Review” thereafter.Once you did all of that, you can click “Publish” and after a few seconds, the message should show up on your device. # Reacting to Incoming Messages
By now, we can send push notifications to both Android and iOS Flutter apps. But user interaction with those incoming messages is not supported yet.Typically, we want to open our app and maybe do something inside of that app (e.g. load a specific page) when we receive a message.This can easily be implemented with help of the Firebase messaging package which we’re alread using.There, you can react to various events by adding this code:You have three event handlers:onMessage
: Triggered if a message is received whilst the app is in foregroundonResume
: Triggered if a message is received whilst the app is in backgroundonLaunch
: Triggered if a message is received if the app was terminated
Flutter Run Ios
You find a detailed table here.Adobe premiere pro cc 2020 14.0.1. Now it’s up to you what you want to do in those handlers. You could switch to a different route, show some alert or overlay to the user or do anything else you need to do. # Configuration Options
There’s more which you can configure and do. I strongly recommend that you also have a detailed look at the Firebase messaging package docs for more information. # Next Steps
In this tutorial, we added push notifications such that you can directly send them via the Cloud Messaging web UI. Sometimes, that is exactly what you want (e.g. to deliver marketing messages to your users).Sometimes, you also want to send out automated messages - for example in a chat app.That’s something I also show in my Flutter course. And in general, you find a detailed video guide on Flutter, realtime messaging, push notifications and much more in that course!
Running
flutter upgrade
will automatically run flutter doctor.
If this a fresh Flutter install and no upgrade was necessary, then run flutter doctor
manually. It will report if there are any dependencies you need to install to complete the setup. Feel free to ignore the check marks that are not relevant for you (for example Xcode if you do not intend to develop for iOS).material-components-flutter-codelabs-101-starter/mdc_100_series directory.The right branch
Codelabs MDC-101 through 104 consecutively build upon each other. So when you finish the code for 101, it becomes the starter code for 102! The code is divided across different branches, and you can list them all with this command:git branch --list
To see the completed code, checkout the 102-starter_and_101-complete
branch.Tip: Make sure you have the plugins installed for Flutter and Dart.1. Open Android Studio.2. If you see the welcome screen, click Open an existing Android Studio project. 3. Navigate to the material-components-flutter-codelabs/mdc_100_series
directory and click Open. The project should open. You can ignore any errors you see in Dart Analysis until you've built the project once. 4. If prompted: - Install any platform and plugin updates or FlutterRunConfigurationType.
- If the Dart or Flutter SDK is not configured, set the Flutter SDK path for the Flutter plugin.
- Configure Android frameworks.
- Click on 'Get dependencies' or 'Run ‘flutter packages get'.
Then restart Android Studio. 1. Select the device or emulator.If the Android emulator is not already running, select Tools -> Android -> AVD Manager to create a virtual device and start the emulator. If an AVD already exists, you can start the emulator directly from the device selector in Android Studio, as shown in the next step.(For the iOS Simulator, if it is not already running, launch the simulator on your development machine by selecting Flutter Device Selection -> Open iOS Simulator.) 2. Start your Flutter app:- Look for the Flutter Device Selection dropdown menu at the top of your editor screen, and select the device (for example, iPhone SE or Android SDK built for <version>).
- Press the Play icon ().
If you were unable to run the app successfully, stop and troubleshoot your developer environment. Try navigating to material-components-flutter-codelabs
or if you downloaded the .zip file material-components-flutter-codelabs-.
) in the terminal and running flutter create mdc_100_series
.Success! The starter code for Shrine's login page should be running in your simulator. You should see the Shrine logo and the name 'Shrine' just below it.Android iOS
Let's look at the code.login.dart
Paint 3d pressure sensitivity. Open up login.dart
. It should contain this:Notice that it contains an import
statement and two new classes:- The
import
statement brings Material Components into this file. - The
LoginPage
class represents the entire page displayed in the simulator. - The
_LoginPageState
class's build()
function controls how all the widgets in our UI are created.
For more of the basics of the Flutter UI and what widgets are, you can take a Tour of the Flutter Widget Framework or do the codelab Write Your First Flutter App, part 1.To begin, we'll add two text fields to our login page, where users enter their username and password. We'll use the TextField widget, which displays a floating label and activates a touch ripple.Material's text fields have been greatly enhanced to improve brand flexibility, with improvements backed by extensive user experience (UX) research for better usability and visual design.Learn more about the new text fields in their article of the Material Guidelines.This page is structured primarily with a ListView, which arranges its children in a scrollable column. Let's place text fields at the bottom.SizedBox(height: 120.0).The text fields each have a decoration:
field that takes an InputDecoration widget. The filled:
field means the background of the text field is lightly filled in to help people recognize the tap or touch target area of the text field. The second text field's obscureText: true
value automatically replaces the input that the user types with bullets, which is appropriate for passwords.Save your project (with the keystroke: command + s) which performs a hot reload.You should now see a page with two text fields for Username and Password! Check out the floating label animation:Android iOS
If the app doesn't update, click the 'Play' button again, or click 'Stop' followed by 'Play.'TextField features include:- The TextField widget's look can be easily changed. For the decoration field, specify an InputDecoration value.
- The MDC text field displays touch feedback (called the MDC ripple or 'ink') by default.
- The FormField is a similar widget that has special features for embedding fields in Forms.
Next, we'll add two buttons to our login page: 'Cancel' and 'Next.' We'll use two kinds of MDC button widgets: the FlatButton (called the 'Text Button' in the Material Guidelines) and the RaisedButton (referred to as the 'Contained Button').Learn more about button hierarchy in the Buttons article of the Material Guidelines.ButtonBar to the ListView
's children:The ButtonBar arranges its children in a row.Flutter Test Setup
Then add two buttons to the ButtonBar's list of children
:For more information on buttons and their interactions, see Adding Interactivity to Your App.Save your project. Under the last text field, you should see two buttons appear:
Android iOS
The ButtonBar handles the layout work for you. It positions the buttons horizontally, so they appear next to one another, according to the padding in the current ButtonTheme. (You'll learn more about that in codelab MDC-103.)Touching a button initiates an ink ripple animation, without causing anything else to happen. Let's add functionality into the anonymous onPressed:
functions, so that the cancel button clears the text fields, and the next button dismisses the screen:TextEditingControllers to control their text.Right under the _LoginPageState
class's declaration, add the controllers as final
variables.On the first text field's controller:
field, set the _usernameController
:On the second text field's controller:
field, now set the _passwordController
:onPressed:
function:Save your project. Now when you type something into the text fields, hitting cancel clears each field again.This login form is in good shape! Let's advance our users to the rest of the Shrine app.app.dart of our app, calling initialRoute: '/login',
adds the login screen to the Navigator, on top of what is passed in home:
.Learn more about routes and navigation in Navigation Basics.In the RaisedButton's onPressed:
function, pop the most recent route from the Navigator:Lastly, open up home.dart
and set resizeToAvoidBottomInset
to false
in the Scaffold
:Doing this ensures that the keyboard's appearance does not alter the size of the home page or its widgets.That's it! Save the project. Go ahead and click 'Next.'You did it!Android iOS
This screen is the starting point for our next codelab, which you'll work on in MDC-102.About Buttons:- In addition to FlatButton and RaisedButton, there's OutlineButton, FloatingActionButton IconButton, and more.
- Browse buttons and their documentation in the MDC Widgets catalog.
We added text fields and buttons and hardly had to consider layout code. Material Components for Flutter come with a lot of style and can be placed on screen almost effortlessly.The completed MDC-101 app is available in the 102-starter_and_101-complete
branch.You can test your version of the app against the app in that branch.Alternatively, head over to MDC-102: Material Design Structure and Layout to learn about the components covered in MDC-102 for Flutter.I was able to complete this codelab with a reasonable amount of time and effort
Strongly agree Agree Neutral Disagree Strongly disagree I would like to continue using Material Components in the future
Strongly agree Agree Neutral Disagree Strongly disagree Important: If you want to see a detailed video guide on how to add push Flutter push notifications to Flutter apps, check out my complete Flutter course. There, you not only learn Flutter from scratch but you also find a complete section where we build a Chat App that also uses Push Notifications to deliver messages!Push Notifications are a common feature in mobile apps, yet adding them can be tricky. Or at least, it involves a couple of steps that you have to go through.This guide provides you with all the steps for Android and iOS apps built with Flutter. # How Do Push Notifications Work?
As you’ll see below, it takes a couple of steps to add push notifications to an app. The reason for that mainly is security - after all you definitely don’t want anyone to send out push messages to your apps’ users.Before we actually write any code, it’s important to understand how push notifications work. You can skip this and jump right ahead to the Android or iOS parts but I strongly recommend that you pick up these important basics first!Here’s how Push Notifications are delivered to your app / the users of your app:Let me explain this image.First of all, you have to understand that you have two “ends”: The frontend (your app, running on your users’ devices) and the backend (a server you own which does the “behind the scenes” work). For more information on that, check out our Frontend vs Backend article.We need both ends because you are most likely not just deliver a nice app UI to your users. Instead, your app probably should be able to offer certain features to your users.For example:- Authentication (Signup & Login)
- Storing data in a database (e.g. chat messages)
- Storing uploaded images (e.g. user photos)
These are the kind of things your backend server does. Your Flutter app communicates with that server - all these features are by the way also covered in my Flutter course.Back to the image.The natural thing would be that you simply push a notification from your backend to the frontend and that then shows that notification on the user’s device, even if your app is in the background at the moment.But it doesn’t work like that.You absolutely can communicate like this with your app if it’s in the foreground. But if it’s in the background (i.e. currently not running), you need help from the device’s operating system (iOS or Android) because it’s the operating system that shows the notification in the end. You can’t directly communicate with your app, if it’s not running at the moment.Both Android and iOS don’t work such that they expose a simple API to which you can send a request, which then in turn what lead to a notification being shown on the device.Why?Because that would be highly insecure!Anyone could be pushing to any device - and we definitely don’t want that!Therefore, as a developer, you have to register your app with Google and Apple and let them know that you plan on having push notifications as part of your app. You’ll then get a unique key which you can use to send a “please deliver this message” request to Google’s or Apple’s push services and those services then go ahead and deliver the message to the devices (where the message is shown then).So long story short - we need to do the following things in order to be able to deliver push notifications:- Register our app with Google and Apple and let them know that we want to send push notifications
- Use the key / certificate that we get for sending messages
- Add code to our app to define what should happen if a user interacts with a received push notification
# Adding Push Notifications to Android Flutter Apps
Let’s add push notifications to an Android Flutter app.Since Android is Google’s mobile operating system, we need to use Google’s push notification service to deliver the message (why? see above). This service is called FCM (Firebase Cloud Messaging). Firebase simply is a product offered by Google. Firebase offers more than just push notifications but the push service is part of it.First of all, you need to sign up with Firebase and log into the Firebase Console. Run ipa on pc.There, you then need to add a new Android app.Simply follow the assistant and download the generated google-services.json
file to your Flutter project. There, store it in the android/app
folder.Next, edit your android/build.gradle
file and add the following line to dependencies
:Also edit the android/app/build.gradle
file to add this line of code at the bottom of the file:That’s it, this generally prepares your Android app to be able to receive (but not yet handle) push notifications.The google-services.json
basically is that unique key I mentioned earlier. It contains unique identification data which tells Android that your app is registered to receive push notifications.Keep in mind that we did register it in the Firebase console. Firebase is a Google service and therefore Google is now aware of your app.Of course just adding the google-services.json
file to your project is not enough - it’s not going to be parsed and interepreted by your app automatically.Instead, we now need to add a new Flutter library to our project: The Firebase Messaging package.To install it, add the following entry to your pubspec.yaml
file:(the version can differ, find the latest version here)Thereafter, your IDE either picks it up automatically and installs it or you need to runNow we need to add some code to our Flutter app.At some point, we need to initialize the messaging package and also ask the user for permission. This could be done in the main.dart
file but you can do it anywhere (e.g. you could also do it on some screen that shows up after authentication).Once all of that is done, you can build your app and test it on an emulator or a real device.Thereafter, you can try sending a message via the Firebase web push console.Go to “Cloud Messaging” in your Firebase project console (you find it under “Grow”) and click on “Send your first message”.What is latest ios for macbook pro. Simply enter a title and a notification text and click on “Next”.In the “Target” part, simply choose “App” and then select your registered Android app in the dropdown.Click “Next” again and keep “Now” Go player pc. as a scheduled time.Click “Next” on last time (you don’t need to add any data on that final screen) and select “Review” thereafter.Once you did all of that, you can click “Publish” and after a few seconds, the message should show up on your device.Important: You can test Android push notifications both on an emulator as well as a real device. Your Flutter app of course needs to be installed on that device.At the moment, we got no control over what happens when a user reacts to a push notification (e.g. when the notification gets clicked). We’ll work on this in the later, after we added iOS push notifications. Of course you can jump right ahead if you don’t plan on supporting iOS. # Adding Push Notifications to iOS Flutter Apps
I strongly recommend that you go through the Adding Push Notifications to Android Apps part first, since that knowledge will help a lot in this part as well.Because there’s one really cool thing: Even though we have to use “APNs” for push notifications that should be delivered to iOS devices, we can continue using “FCM” (the service we needed for Android).Why?Because “FCM” supports both Android and iOS!For Android, it simply sends the messages itself, for iOS, it basically forwards your message to “APNs”. So you can use one service for both and that of course helps a lot!We still need to let Apple know about our intents though and we therefore still need to go through a couple of iOS-specific steps. But we will be using the “FCM” and also the Firebase Messaging Flutter package we used before.So first of all, you should go back to your Firebase web console and add your iOS app as well.For that, on the starting page of the console, click on “Add app” and then select the iOS icon.Go through the wizard (only until “Download config file” though) and download the GoogleService-Info.plist
file. Open your ios/Runner.xcworkspace
file with XCode and then add the GoogleService-Info.plist
file to the project.Skip the rest of the wizard (i.e. don’t go through the “Add Firebase SDK” step and the following steps).We now need to let iOS know about the fact that our apps wants to use push notifications. For that, select “Runner” in XCode and turn on “Push Notifications” and “Background Modes” in the “Signing & Capabilities” tab.Thereafter, under “Background Modes”, check “Remote notifications” and “Background fetch”. https://bestffiles158.weebly.com/canvas-tech-zachary-mac-os.html.We’re almost there, just a few steps left!As mentioned before, “FCM” is going to forward our to-be-delivered messages to “APNs”. Hence we also need to register our app with “APNs”. Do that as described here. Skip the “Create the Provisioning Profile” step!As part of the previous step, you’ll get an “APNs” authentication key (a file you had to download in the last step).This key file now needs to be uploaded to “FCM” so that this service is able to “talk to APNs”. Upload it as described here.And with that, we’re done!Make sure you added the Firebase messaging package to your Flutter app (also see the Android part of this article for more details).Last but not least, just as with Android, we need to add some Flutter code to be prepared to receive messages (and to ask for permission). If you already followed the Android instructions from above, you already have the below code snippet:With all of that done, you can save everything and re-build your Flutter app to test this.Important: Unlike for Android, you need a real iOS device to test iOS push notifications! You can’t test those on a simulator!We can test push notifications with the same steps as for Android:Go to “Cloud Messaging” in your Firebase project console (you find it under “Grow”) and click on “Send your first message”.Simply enter a title and a notification text and click on “Next”.In the “Target” part, simply choose “App” and then select your registered iOS app in the dropdown.Click “Next” again and keep “Now” as a scheduled time.Click “Next” on last time (you don’t need to add any data on that final screen) and select “Review” thereafter.Once you did all of that, you can click “Publish” and after a few seconds, the message should show up on your device. # Reacting to Incoming Messages
By now, we can send push notifications to both Android and iOS Flutter apps. But user interaction with those incoming messages is not supported yet.Typically, we want to open our app and maybe do something inside of that app (e.g. load a specific page) when we receive a message.This can easily be implemented with help of the Firebase messaging package which we’re alread using.There, you can react to various events by adding this code:You have three event handlers:onMessage
: Triggered if a message is received whilst the app is in foregroundonResume
: Triggered if a message is received whilst the app is in backgroundonLaunch
: Triggered if a message is received if the app was terminated
Flutter Run Ios
You find a detailed table here.Adobe premiere pro cc 2020 14.0.1. Now it’s up to you what you want to do in those handlers. You could switch to a different route, show some alert or overlay to the user or do anything else you need to do. # Configuration Options
There’s more which you can configure and do. I strongly recommend that you also have a detailed look at the Firebase messaging package docs for more information. # Next Steps
In this tutorial, we added push notifications such that you can directly send them via the Cloud Messaging web UI. Sometimes, that is exactly what you want (e.g. to deliver marketing messages to your users).Sometimes, you also want to send out automated messages - for example in a chat app.That’s something I also show in my Flutter course. And in general, you find a detailed video guide on Flutter, realtime messaging, push notifications and much more in that course!
The right branch
Codelabs MDC-101 through 104 consecutively build upon each other. So when you finish the code for 101, it becomes the starter code for 102! The code is divided across different branches, and you can list them all with this command:
git branch --list
To see the completed code, checkout the
102-starter_and_101-complete
branch.1. Open Android Studio.
2. If you see the welcome screen, click Open an existing Android Studio project.
3. Navigate to the
material-components-flutter-codelabs/mdc_100_series
directory and click Open. The project should open. You can ignore any errors you see in Dart Analysis until you've built the project once.4. If prompted:
- Install any platform and plugin updates or FlutterRunConfigurationType.
- If the Dart or Flutter SDK is not configured, set the Flutter SDK path for the Flutter plugin.
- Configure Android frameworks.
- Click on 'Get dependencies' or 'Run ‘flutter packages get'.
Then restart Android Studio.
1. Select the device or emulator.If the Android emulator is not already running, select Tools -> Android -> AVD Manager to create a virtual device and start the emulator. If an AVD already exists, you can start the emulator directly from the device selector in Android Studio, as shown in the next step.(For the iOS Simulator, if it is not already running, launch the simulator on your development machine by selecting Flutter Device Selection -> Open iOS Simulator.) |
2. Start your Flutter app:
|
If you were unable to run the app successfully, stop and troubleshoot your developer environment. Try navigating to
material-components-flutter-codelabs
or if you downloaded the .zip file material-components-flutter-codelabs-.
) in the terminal and running flutter create mdc_100_series
.Success! The starter code for Shrine's login page should be running in your simulator. You should see the Shrine logo and the name 'Shrine' just below it.
Android | iOS |
Let's look at the code.
login.dart
Paint 3d pressure sensitivity. Open up
login.dart
. It should contain this:Notice that it contains an
import
statement and two new classes:- The
import
statement brings Material Components into this file. - The
LoginPage
class represents the entire page displayed in the simulator. - The
_LoginPageState
class'sbuild()
function controls how all the widgets in our UI are created.
For more of the basics of the Flutter UI and what widgets are, you can take a Tour of the Flutter Widget Framework or do the codelab Write Your First Flutter App, part 1.
To begin, we'll add two text fields to our login page, where users enter their username and password. We'll use the TextField widget, which displays a floating label and activates a touch ripple.
Material's text fields have been greatly enhanced to improve brand flexibility, with improvements backed by extensive user experience (UX) research for better usability and visual design.
Learn more about the new text fields in their article of the Material Guidelines.
This page is structured primarily with a ListView, which arranges its children in a scrollable column. Let's place text fields at the bottom.
SizedBox(height: 120.0).The text fields each have a decoration:
field that takes an InputDecoration widget. The filled:
field means the background of the text field is lightly filled in to help people recognize the tap or touch target area of the text field. The second text field's obscureText: true
value automatically replaces the input that the user types with bullets, which is appropriate for passwords.Save your project (with the keystroke: command + s) which performs a hot reload.You should now see a page with two text fields for Username and Password! Check out the floating label animation:Android iOS
If the app doesn't update, click the 'Play' button again, or click 'Stop' followed by 'Play.'TextField features include:- The TextField widget's look can be easily changed. For the decoration field, specify an InputDecoration value.
- The MDC text field displays touch feedback (called the MDC ripple or 'ink') by default.
- The FormField is a similar widget that has special features for embedding fields in Forms.
Next, we'll add two buttons to our login page: 'Cancel' and 'Next.' We'll use two kinds of MDC button widgets: the FlatButton (called the 'Text Button' in the Material Guidelines) and the RaisedButton (referred to as the 'Contained Button').Learn more about button hierarchy in the Buttons article of the Material Guidelines.ButtonBar to the ListView
's children:The ButtonBar arranges its children in a row.Flutter Test Setup
Then add two buttons to the ButtonBar's list of children
:For more information on buttons and their interactions, see Adding Interactivity to Your App.Save your project. Under the last text field, you should see two buttons appear:
The text fields each have a
decoration:
field that takes an InputDecoration widget. The filled:
field means the background of the text field is lightly filled in to help people recognize the tap or touch target area of the text field. The second text field's obscureText: true
value automatically replaces the input that the user types with bullets, which is appropriate for passwords.Save your project (with the keystroke: command + s) which performs a hot reload.
You should now see a page with two text fields for Username and Password! Check out the floating label animation:
Android | iOS |
If the app doesn't update, click the 'Play' button again, or click 'Stop' followed by 'Play.'
TextField features include:
- The TextField widget's look can be easily changed. For the decoration field, specify an InputDecoration value.
- The MDC text field displays touch feedback (called the MDC ripple or 'ink') by default.
- The FormField is a similar widget that has special features for embedding fields in Forms.
Next, we'll add two buttons to our login page: 'Cancel' and 'Next.' We'll use two kinds of MDC button widgets: the FlatButton (called the 'Text Button' in the Material Guidelines) and the RaisedButton (referred to as the 'Contained Button').
ListView
's children:The ButtonBar arranges its children in a row.
Flutter Test Setup
Then add two buttons to the ButtonBar's list of
children
:For more information on buttons and their interactions, see Adding Interactivity to Your App.
Save your project. Under the last text field, you should see two buttons appear:
Android | iOS |
The ButtonBar handles the layout work for you. It positions the buttons horizontally, so they appear next to one another, according to the padding in the current ButtonTheme. (You'll learn more about that in codelab MDC-103.)
Touching a button initiates an ink ripple animation, without causing anything else to happen. Let's add functionality into the anonymous
TextEditingControllers to control their text.onPressed:
functions, so that the cancel button clears the text fields, and the next button dismisses the screen:Right under the
_LoginPageState
class's declaration, add the controllers as final
variables.On the first text field's
controller:
field, set the _usernameController
:On the second text field's
controller:
field, now set the _passwordController
:onPressed:
function:Save your project. Now when you type something into the text fields, hitting cancel clears each field again.
This login form is in good shape! Let's advance our users to the rest of the Shrine app.
app.dart of our app, calling initialRoute: '/login',
adds the login screen to the Navigator, on top of what is passed in home:
.Learn more about routes and navigation in Navigation Basics.In the RaisedButton's onPressed:
function, pop the most recent route from the Navigator:Lastly, open up home.dart
and set resizeToAvoidBottomInset
to false
in the Scaffold
:Doing this ensures that the keyboard's appearance does not alter the size of the home page or its widgets.That's it! Save the project. Go ahead and click 'Next.'You did it!Android iOS
This screen is the starting point for our next codelab, which you'll work on in MDC-102.About Buttons:- In addition to FlatButton and RaisedButton, there's OutlineButton, FloatingActionButton IconButton, and more.
- Browse buttons and their documentation in the MDC Widgets catalog.
We added text fields and buttons and hardly had to consider layout code. Material Components for Flutter come with a lot of style and can be placed on screen almost effortlessly.The completed MDC-101 app is available in the 102-starter_and_101-complete
branch.You can test your version of the app against the app in that branch.Alternatively, head over to MDC-102: Material Design Structure and Layout to learn about the components covered in MDC-102 for Flutter.I was able to complete this codelab with a reasonable amount of time and effort
Strongly agree Agree Neutral Disagree Strongly disagree I would like to continue using Material Components in the future
Strongly agree Agree Neutral Disagree Strongly disagree Important: If you want to see a detailed video guide on how to add push Flutter push notifications to Flutter apps, check out my complete Flutter course. There, you not only learn Flutter from scratch but you also find a complete section where we build a Chat App that also uses Push Notifications to deliver messages!Push Notifications are a common feature in mobile apps, yet adding them can be tricky. Or at least, it involves a couple of steps that you have to go through.This guide provides you with all the steps for Android and iOS apps built with Flutter. # How Do Push Notifications Work?
As you’ll see below, it takes a couple of steps to add push notifications to an app. The reason for that mainly is security - after all you definitely don’t want anyone to send out push messages to your apps’ users.Before we actually write any code, it’s important to understand how push notifications work. You can skip this and jump right ahead to the Android or iOS parts but I strongly recommend that you pick up these important basics first!Here’s how Push Notifications are delivered to your app / the users of your app:Let me explain this image.First of all, you have to understand that you have two “ends”: The frontend (your app, running on your users’ devices) and the backend (a server you own which does the “behind the scenes” work). For more information on that, check out our Frontend vs Backend article.We need both ends because you are most likely not just deliver a nice app UI to your users. Instead, your app probably should be able to offer certain features to your users.For example:- Authentication (Signup & Login)
- Storing data in a database (e.g. chat messages)
- Storing uploaded images (e.g. user photos)
These are the kind of things your backend server does. Your Flutter app communicates with that server - all these features are by the way also covered in my Flutter course.Back to the image.The natural thing would be that you simply push a notification from your backend to the frontend and that then shows that notification on the user’s device, even if your app is in the background at the moment.But it doesn’t work like that.You absolutely can communicate like this with your app if it’s in the foreground. But if it’s in the background (i.e. currently not running), you need help from the device’s operating system (iOS or Android) because it’s the operating system that shows the notification in the end. You can’t directly communicate with your app, if it’s not running at the moment.Both Android and iOS don’t work such that they expose a simple API to which you can send a request, which then in turn what lead to a notification being shown on the device.Why?Because that would be highly insecure!Anyone could be pushing to any device - and we definitely don’t want that!Therefore, as a developer, you have to register your app with Google and Apple and let them know that you plan on having push notifications as part of your app. You’ll then get a unique key which you can use to send a “please deliver this message” request to Google’s or Apple’s push services and those services then go ahead and deliver the message to the devices (where the message is shown then).So long story short - we need to do the following things in order to be able to deliver push notifications:- Register our app with Google and Apple and let them know that we want to send push notifications
- Use the key / certificate that we get for sending messages
- Add code to our app to define what should happen if a user interacts with a received push notification
# Adding Push Notifications to Android Flutter Apps
Let’s add push notifications to an Android Flutter app.Since Android is Google’s mobile operating system, we need to use Google’s push notification service to deliver the message (why? see above). This service is called FCM (Firebase Cloud Messaging). Firebase simply is a product offered by Google. Firebase offers more than just push notifications but the push service is part of it.First of all, you need to sign up with Firebase and log into the Firebase Console. Run ipa on pc.There, you then need to add a new Android app.Simply follow the assistant and download the generated google-services.json
file to your Flutter project. There, store it in the android/app
folder.Next, edit your android/build.gradle
file and add the following line to dependencies
:Also edit the android/app/build.gradle
file to add this line of code at the bottom of the file:That’s it, this generally prepares your Android app to be able to receive (but not yet handle) push notifications.The google-services.json
basically is that unique key I mentioned earlier. It contains unique identification data which tells Android that your app is registered to receive push notifications.Keep in mind that we did register it in the Firebase console. Firebase is a Google service and therefore Google is now aware of your app.Of course just adding the google-services.json
file to your project is not enough - it’s not going to be parsed and interepreted by your app automatically.Instead, we now need to add a new Flutter library to our project: The Firebase Messaging package.To install it, add the following entry to your pubspec.yaml
file:(the version can differ, find the latest version here)Thereafter, your IDE either picks it up automatically and installs it or you need to runNow we need to add some code to our Flutter app.At some point, we need to initialize the messaging package and also ask the user for permission. This could be done in the main.dart
file but you can do it anywhere (e.g. you could also do it on some screen that shows up after authentication).Once all of that is done, you can build your app and test it on an emulator or a real device.Thereafter, you can try sending a message via the Firebase web push console.Go to “Cloud Messaging” in your Firebase project console (you find it under “Grow”) and click on “Send your first message”.What is latest ios for macbook pro. Simply enter a title and a notification text and click on “Next”.In the “Target” part, simply choose “App” and then select your registered Android app in the dropdown.Click “Next” again and keep “Now” Go player pc. as a scheduled time.Click “Next” on last time (you don’t need to add any data on that final screen) and select “Review” thereafter.Once you did all of that, you can click “Publish” and after a few seconds, the message should show up on your device.Important: You can test Android push notifications both on an emulator as well as a real device. Your Flutter app of course needs to be installed on that device.At the moment, we got no control over what happens when a user reacts to a push notification (e.g. when the notification gets clicked). We’ll work on this in the later, after we added iOS push notifications. Of course you can jump right ahead if you don’t plan on supporting iOS. # Adding Push Notifications to iOS Flutter Apps
I strongly recommend that you go through the Adding Push Notifications to Android Apps part first, since that knowledge will help a lot in this part as well.Because there’s one really cool thing: Even though we have to use “APNs” for push notifications that should be delivered to iOS devices, we can continue using “FCM” (the service we needed for Android).Why?Because “FCM” supports both Android and iOS!For Android, it simply sends the messages itself, for iOS, it basically forwards your message to “APNs”. So you can use one service for both and that of course helps a lot!We still need to let Apple know about our intents though and we therefore still need to go through a couple of iOS-specific steps. But we will be using the “FCM” and also the Firebase Messaging Flutter package we used before.So first of all, you should go back to your Firebase web console and add your iOS app as well.For that, on the starting page of the console, click on “Add app” and then select the iOS icon.Go through the wizard (only until “Download config file” though) and download the GoogleService-Info.plist
file. Open your ios/Runner.xcworkspace
file with XCode and then add the GoogleService-Info.plist
file to the project.Skip the rest of the wizard (i.e. don’t go through the “Add Firebase SDK” step and the following steps).We now need to let iOS know about the fact that our apps wants to use push notifications. For that, select “Runner” in XCode and turn on “Push Notifications” and “Background Modes” in the “Signing & Capabilities” tab.Thereafter, under “Background Modes”, check “Remote notifications” and “Background fetch”. https://bestffiles158.weebly.com/canvas-tech-zachary-mac-os.html.We’re almost there, just a few steps left!As mentioned before, “FCM” is going to forward our to-be-delivered messages to “APNs”. Hence we also need to register our app with “APNs”. Do that as described here. Skip the “Create the Provisioning Profile” step!As part of the previous step, you’ll get an “APNs” authentication key (a file you had to download in the last step).This key file now needs to be uploaded to “FCM” so that this service is able to “talk to APNs”. Upload it as described here.And with that, we’re done!Make sure you added the Firebase messaging package to your Flutter app (also see the Android part of this article for more details).Last but not least, just as with Android, we need to add some Flutter code to be prepared to receive messages (and to ask for permission). If you already followed the Android instructions from above, you already have the below code snippet:With all of that done, you can save everything and re-build your Flutter app to test this.Important: Unlike for Android, you need a real iOS device to test iOS push notifications! You can’t test those on a simulator!We can test push notifications with the same steps as for Android:Go to “Cloud Messaging” in your Firebase project console (you find it under “Grow”) and click on “Send your first message”.Simply enter a title and a notification text and click on “Next”.In the “Target” part, simply choose “App” and then select your registered iOS app in the dropdown.Click “Next” again and keep “Now” as a scheduled time.Click “Next” on last time (you don’t need to add any data on that final screen) and select “Review” thereafter.Once you did all of that, you can click “Publish” and after a few seconds, the message should show up on your device. # Reacting to Incoming Messages
By now, we can send push notifications to both Android and iOS Flutter apps. But user interaction with those incoming messages is not supported yet.Typically, we want to open our app and maybe do something inside of that app (e.g. load a specific page) when we receive a message.This can easily be implemented with help of the Firebase messaging package which we’re alread using.There, you can react to various events by adding this code:You have three event handlers:onMessage
: Triggered if a message is received whilst the app is in foregroundonResume
: Triggered if a message is received whilst the app is in backgroundonLaunch
: Triggered if a message is received if the app was terminated
Flutter Run Ios
You find a detailed table here.Adobe premiere pro cc 2020 14.0.1. Now it’s up to you what you want to do in those handlers. You could switch to a different route, show some alert or overlay to the user or do anything else you need to do. # Configuration Options
There’s more which you can configure and do. I strongly recommend that you also have a detailed look at the Firebase messaging package docs for more information. # Next Steps
In this tutorial, we added push notifications such that you can directly send them via the Cloud Messaging web UI. Sometimes, that is exactly what you want (e.g. to deliver marketing messages to your users).Sometimes, you also want to send out automated messages - for example in a chat app.That’s something I also show in my Flutter course. And in general, you find a detailed video guide on Flutter, realtime messaging, push notifications and much more in that course!
Learn more about routes and navigation in Navigation Basics.
In the RaisedButton's
onPressed:
function, pop the most recent route from the Navigator:Lastly, open up
home.dart
and set resizeToAvoidBottomInset
to false
in the Scaffold
:Doing this ensures that the keyboard's appearance does not alter the size of the home page or its widgets.
That's it! Save the project. Go ahead and click 'Next.'
You did it!
Android | iOS |
This screen is the starting point for our next codelab, which you'll work on in MDC-102.
About Buttons:
- In addition to FlatButton and RaisedButton, there's OutlineButton, FloatingActionButton IconButton, and more.
- Browse buttons and their documentation in the MDC Widgets catalog.
We added text fields and buttons and hardly had to consider layout code. Material Components for Flutter come with a lot of style and can be placed on screen almost effortlessly.
The completed MDC-101 app is available in the
102-starter_and_101-complete
branch.You can test your version of the app against the app in that branch.
I was able to complete this codelab with a reasonable amount of time and effort
I would like to continue using Material Components in the future
google-services.json
file to your Flutter project. There, store it in the android/app
folder.android/build.gradle
file and add the following line to dependencies
:android/app/build.gradle
file to add this line of code at the bottom of the file:google-services.json
basically is that unique key I mentioned earlier. It contains unique identification data which tells Android that your app is registered to receive push notifications.google-services.json
file to your project is not enough - it’s not going to be parsed and interepreted by your app automatically.pubspec.yaml
file:main.dart
file but you can do it anywhere (e.g. you could also do it on some screen that shows up after authentication).GoogleService-Info.plist
file. Open your ios/Runner.xcworkspace
file with XCode and then add the GoogleService-Info.plist
file to the project.onMessage
: Triggered if a message is received whilst the app is in foregroundonResume
: Triggered if a message is received whilst the app is in backgroundonLaunch
: Triggered if a message is received if the app was terminated