This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:firebase_messaging/firebase_messaging.dart'; | |
class PushNotificationsManager { | |
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. | |
_firebaseMessaging.requestNotificationPermissions(); | |
_firebaseMessaging.configure(); | |
// For testing purposes print the Firebase Messaging token | |
String token = await _firebaseMessaging.getToken(); | |
print("FirebaseMessaging token: $token"); | |
_initialized = true; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
These method calls not exist in latest flutter_message version.
firebase_messaging: ^10.0.5