fcm_token_sync 1.0.1
fcm_token_sync: ^1.0.1 copied to clipboard

A widget which keeps your FCM token in sync with your backend

FCM Token Sync #

A widget which keeps your FCM token in sync with your backend

style: very good analysis Gitmoji Pub Version GitHub GitHub Workflow Status Coverage Status

✨ Features #

  • Keeps your user's FCM tokens in sync with your backend
  • Automatically handles permission requests
  • 100% test coverage
  • Null-safety

🚀 Installation #

Install from pub.dev:

fcm_token_sync: ^1.0.1

✅ Prerequisites #

You should already have Firebase Cloud Messaging set up in your project. Go here for setup instructions.

Additionally, you will need to have built a way to send FCM tokens to your backend service.

🔨 Usage #

This package contains a FcmTokenSync widget, which you can wrap around any widget in your project.

Some recommendations for usage:

  • Add this widget to your tree wherever you want to ask your user for notification permissions.
  • This will probably be after the user has registered and/or signed in.

Example #

class HomePage extends StatelessWidget {
    const HomePage({Key? key}) : super(key: key);

    @override
    Widget build(BuildContext context) {
        return FcmTokenSync(
            firebaseMessaging: FirebaseMessaging.instance,
            onToken: _updateFcmToken,
            child: Scaffold(), // Widget to display here
        );
    }

    Future<void> _updateFcmToken(String token) async {
        // Send the updated token to your backend here.
    }
}

👨🏻‍💻 Authors #

0
likes
120
pub points
41%
popularity

Publisher

Unknown

A widget which keeps your FCM token in sync with your backend

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

firebase_messaging, flutter

More

Packages that depend on fcm_token_sync