File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -51,19 +51,24 @@ class Application extends StatefulWidget {
51
51
class _Application extends State<Application> {
52
52
String _token;
53
53
54
- @override
55
- void initState() async {
56
- super.initState();
54
+ Future<void> setupToken() async {
57
55
// Get the token each time the application loads
58
- String token = await FirebaseMessaging.instance.getToken();
56
+ String? token = await FirebaseMessaging.instance.getToken();
59
57
60
58
// Save the initial token to the database
61
- await saveTokenToDatabase(token);
59
+ await saveTokenToDatabase(token! );
62
60
63
61
// Any time the token refreshes, store this in the database too.
64
62
FirebaseMessaging.instance.onTokenRefresh.listen(saveTokenToDatabase);
65
63
}
66
64
65
+ @override
66
+ void initState() {
67
+ super.initState();
68
+
69
+ setupToken();
70
+ }
71
+
67
72
@override
68
73
Widget build(BuildContext context) {
69
74
return Text("...");
You can’t perform that action at this time.
0 commit comments