-
-
Save JFernandoGomez/a5406951a954abb0974c1cefa03dd41c to your computer and use it in GitHub Desktop.
This file contains hidden or 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