Skip to content

Instantly share code, notes, and snippets.

Created August 5, 2019 09:23
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save SebastianEngel/0769b50cb2ba6962248341f1fbd508f4 to your computer and use it in GitHub Desktop.
import 'package:firebase_messaging/firebase_messaging.dart';
class PushNotificationsManager {
factory PushNotificationsManager() => _instance;
static final PushNotificationsManager _instance = PushNotificationsManager._();
final FirebaseMessaging _firebaseMessaging = FirebaseMessaging();
bool _initialized = false;
Future<void> init() async {
if (!_initialized) {
// For iOS request permission first.
// For testing purposes print the Firebase Messaging token
String token = await _firebaseMessaging.getToken();
print("FirebaseMessaging token: $token");
_initialized = true;
Copy link

raLaaaa commented Jul 1, 2020


Future main() async {
  PushNotificationsManager().init(); <--

That's the way I do it.

Copy link

meroo36 commented Jul 17, 2020

Future<void> main() async {

Copy link

final FirebaseMessaging _firebaseMessaging = FirebaseMessaging();


These method calls not exist in latest flutter_message version.

firebase_messaging: ^10.0.5

Copy link

monta42 commented Jan 3, 2024

Some replacements are needed:

final FirebaseMessaging _firebaseMessaging = FirebaseMessaging.instance;


      // _firebaseMessaging.configure(); -> configure() has been removed


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment