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_core/firebase_core.dart'; | |
| import 'package:flutter/material.dart'; | |
| import 'package:flutter_fcm_web_example/my_app.dart'; | |
| void main() async { | |
| WidgetsFlutterBinding.ensureInitialized(); | |
| await Firebase.initializeApp(); | |
| runApp(MyApp()); | |
| } |
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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta content="IE=Edge" http-equiv="X-UA-Compatible"> | |
| <meta name="description" content="A new Flutter project."> | |
| <!-- iOS meta tags & icons --> | |
| <meta name="apple-mobile-web-app-capable" content="yes"> |
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:flutter_fcm_web_example/notification_model.dart'; | |
| abstract class NotificationHelper { | |
| Future<bool> get isReady; | |
| Stream<NotificationModel> get stream; | |
| void close(); | |
| Future<String> getToken([bool force = false]); | |
| Future<dynamic> requestPermission(); | |
| } |
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 'dart:async'; | |
| import 'package:firebase_messaging/firebase_messaging.dart'; | |
| import 'package:flutter/foundation.dart'; | |
| import 'package:flutter_fcm_web_example/notification_helper.dart'; | |
| import 'package:flutter_fcm_web_example/notification_model.dart'; | |
| /// Mobile-only helper to manage notifications. | |
| class FirebaseMessagingHelper implements NotificationHelper { | |
| FirebaseMessagingHelper._internal(); |
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 'dart:async'; | |
| import 'package:flutter/foundation.dart'; | |
| import 'package:flutter_fcm_web_example/notification_helper.dart'; | |
| import 'package:firebase/firebase.dart' as firebaseWeb; | |
| import 'package:flutter_fcm_web_example/notification_model.dart'; | |
| /// Web-only helper to manage notifications. | |
| class FirebaseMessagingHelper implements NotificationHelper { | |
| FirebaseMessagingHelper._internal(); |
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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta content="IE=Edge" http-equiv="X-UA-Compatible"> | |
| <meta name="description" content="A new Flutter project."> | |
| <!-- iOS meta tags & icons --> | |
| <meta name="apple-mobile-web-app-capable" content="yes"> |
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
| importScripts('https://www.gstatic.com/firebasejs/7.23.0/firebase-app.js'); | |
| importScripts('https://www.gstatic.com/firebasejs/7.23.0/firebase-messaging.js'); | |
| var firebaseConfig = { | |
| apiKey: "API_KEY", | |
| authDomain: "AUTH_DOMAIN", | |
| databaseURL: "DB_URL", | |
| projectId: "PROJECT_ID", | |
| storageBucket: "STORAGE_BUCKET", | |
| messagingSenderId: "SENDER_ID", |
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:flutter_fcm_web_example/notification_helper.dart'; | |
| import 'firebase_mobile_messaging.dart' | |
| if (dart.library.js) 'firebase_web_messaging.dart' as notifInstance; | |
| abstract class NotificationEncapsulation { | |
| static NotificationHelper get instance => | |
| notifInstance.FirebaseMessagingHelper(); | |
| } |
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 'dart:async'; | |
| import 'package:flutter/material.dart'; | |
| import 'package:flutter_fcm_web_example/notification_encapsulation.dart'; | |
| import 'package:flutter_fcm_web_example/notification_model.dart'; | |
| class MyHomePage extends StatefulWidget { | |
| MyHomePage({Key key, this.title}) : super(key: key); | |
| final String title; |
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 'dart:math' as math; | |
| import 'package:flutter/material.dart'; | |
| const Color darkBlue = Color.fromARGB(255, 18, 32, 47); | |
| final elements = List<int>.generate(100, (i) => i); | |
| void main() { | |
| runApp(MyApp()); |
OlderNewer