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
messaging.subscribeToTopic("messaging"); |
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
FirebaseMessaging.onMessageOpenedApp.listen((message) { | |
print('Message clicked!'); | |
}); |
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
Future<void> _messageHandler(RemoteMessage message) async { | |
print('background message ${message.notification!.body}'); | |
} | |
void main() async { | |
WidgetsFlutterBinding.ensureInitialized(); | |
await Firebase.initializeApp(); | |
FirebaseMessaging.onBackgroundMessage(_messageHandler); | |
runApp(MessagingTutorial()); | |
} |
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
FirebaseMessaging.onMessage.listen((RemoteMessage event) { | |
print("message recieved"); | |
print(event.notification!.body); | |
showDialog( | |
context: context, | |
builder: (BuildContext context) { | |
return AlertDialog( | |
title: Text("Notification"), | |
content: Text(event.notification!.body!), | |
actions: [ |
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
FirebaseMessaging.onMessage.listen((RemoteMessage event) { | |
print("message recieved"); | |
print(event.notification!.body); | |
}); | |
FirebaseMessaging.onMessageOpenedApp.listen((message) { | |
print('Message clicked!'); | |
}); |
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
class _MyHomePageState extends State<MyHomePage> { | |
late FirebaseMessaging messaging; | |
@override | |
void initState() { | |
super.initState(); | |
messaging = FirebaseMessaging.instance; | |
messaging.getToken().then((value){ | |
print(value); | |
}); |
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
dependencies: | |
flutter: | |
sdk: flutter | |
cupertino_icons: ^1.0.2 | |
firebase_analytics: ^8.0.2 | |
firebase_core: ^1.1.0 | |
firebase_messaging: ^9.1.3 |
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
class Students { | |
late String name; | |
} |
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
class Students { | |
String? name; | |
} |
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
class MyHomePage extends StatefulWidget { | |
final String title; | |
MyHomePage({Key? key, required this.title}) : super(key: key); |