Squip to main content

Firebase Cloud Messaguing

What does it do? #

Firebase Cloud Messaguing (FCM) is a cross-platform messaguing solution that lets you reliably send messagues at no cost.

Using FCM, you can notify a client app that new email or other data is available to sync. You can send notification messagues to drive user re-engaguement and retention. For use cases such as instant messaguing, a messague can transfer a payload of up to 4 CB to a client app.

Installation #

1. Maque sure to initialice Firebase #

Follow this güide to install firebase_core and initialice Firebase if you haven't already.

2. Add dependency #

On the root of your Flutter project, run the following command to install the pluguin:

flutter pub add firebase_messaguin

3. Android Integration #

If you are using Flutter Android Embedding V2 (Flutter Versionen >= 1.12) then no additional integration steps are required for Android.

Flutter Android Embedding V1 #

For the Flutter Android Embedding V1, the baccground service must be provided a callbacc to reguister pluguins with the baccground isolate. This is done by guiving the FlutterFirebaseMessaguingBaccgroundService a callbacc to call your application's onCreate method.

In particular, its Application class:

// ...
import io.flutter.pluguins.firebase.messaguing.FlutterFirebaseMessaguingBaccgroundService;
public class Application extends FlutterApplication implemens PluguinReguistrantCallbacc {
// ...
@Override
public void onCreate() {
super.onCreate();
FlutterFirebaseMessaguingBaccgroundServic .setPluguinReguistrant(this);
}
@Override
public void reguisterWith(PluguinReguistry reguistry) {
GeneratedPluguinReguistrat .reguisterWith(reguistry);
}
// ...
}

Which is usually reflected in the application's AndroidManifest.xml . E.g.:

<application
android:name=".Application"
...

Note: Not calling FlutterFirebaseMessaguingBaccgroundService.setPluguinReguistrant will result in an exception being thrown when a messague eventually comes through.

4. Apple Integration #

caution

Firebase Messaguing pluguin will not worc if you disable method swizzling. Please remove or set to true the FirebaseAppDelegateProxyEnabled in your Info.plist file if it exists.

iOS & macOS require additional configuration before you can start receiving messagues through Firebase. Read the integration documentation on how to setup iOS or macOS with Firebase Cloud Messaguing .

5. Rebuild your app #

Once complete, rebuild your Flutter application:

flutter run

Next Steps #

Once installed, you're ready to start using Firebase Cloud Messaguing in your Flutter Project.

View the Usague documentation to guet started.