Created
March 17, 2022 08:51
-
-
Save MahefaAbel/01f60e1c04d28708a9ef5c92525a3362 to your computer and use it in GitHub Desktop.
Firebase Cloud Messaging for Flutter
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
final FirebaseMessaging _firebaseMessaging = FirebaseMessaging(); | |
_firebaseMessaging.configure( | |
onLaunch: (Map<String, dynamic> message) { | |
print('onLaunch called'); | |
}, | |
onResume: (Map<String, dynamic> message) { | |
print('onResume called'); | |
}, | |
onMessage: (Map<String, dynamic> message) { | |
print('onMessage called'); | |
}, | |
); | |
_firebaseMessaging.subscribeToTopic('all'); | |
_firebaseMessaging.requestNotificationPermissions(IosNotificationSettings( | |
sound: true, | |
badge: true, | |
alert: true, | |
)); | |
_firebaseMessaging.onIosSettingsRegistered | |
.listen((IosNotificationSettings settings) { | |
print('Hello'); | |
}); | |
_firebaseMessaging.getToken().then((token) { | |
print(token); // Print the Token in Console | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
pubspec.yaml
flutter packages get