Last active
February 2, 2023 12:15
-
-
Save SteveOye/fd6fedbe4da804e1e2a3c40138660997 to your computer and use it in GitHub Desktop.
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
//import all packages used | |
void main() async { | |
WidgetsBinding widgetsBinding = WidgetsFlutterBinding.ensureInitialized(); | |
NotificationApi.init(); | |
//initial firebase | |
await Firebase.initializeApp( | |
options: DefaultFirebaseOptions.currentPlatform, | |
); | |
runApp(const DruveApp()); | |
} | |
class _NotificationAppState extends State<NotificationApp> { | |
@override | |
void initState() { | |
super.initState(); | |
notificationHandler(); // init the method on state of the application | |
} | |
//create a method that handles notification | |
void notificationHandler() { | |
FirebaseMessaging firebaseMessaging = FirebaseMessaging.instance; | |
FirebaseMessaging.onMessage.listen((event) async { | |
await NotificationApi.pushNotification(event); | |
}); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return GetMaterialApp( | |
initialBinding: ControllerBinding(), | |
fallbackLocale: const Locale('en_US'), | |
getPages: pages, | |
initialRoute: '/', | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment