Home:ALL Converter>How to show push notification in flutter without firebase?

How to show push notification in flutter without firebase?

Ask Time:2020-02-07T14:51:38         Author:Umair

Json Formatter

In my flutter application, i have to show push notification without firebase. My server will send me a message after hitting a particular API, and that message i want to show as a push notification.

Can you show me a way how can i do it in flutter?

Author:Umair,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/60108468/how-to-show-push-notification-in-flutter-without-firebase
Navin Kumar :

You can use Local notification plugin\n\nhttps://pub.dev/packages/flutter_local_notifications\n\nAfter your API response, just show that data in your local notification\n\nFlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = new FlutterLocalNotificationsPlugin(); // initialise the plugin. app_icon needs to be a added as a drawable resource to the Android head project\nvar initializationSettingsAndroid =\n new AndroidInitializationSettings('app_icon');\nvar initializationSettingsIOS = IOSInitializationSettings(\n onDidReceiveLocalNotification: onDidReceiveLocalNotification);\nvar initializationSettings = InitializationSettings(\n initializationSettingsAndroid, initializationSettingsIOS);\nflutterLocalNotificationsPlugin.initialize(initializationSettings,\n onSelectNotification: onSelectNotification);\n",
2020-02-07T09:09:32
techwithsam :

There are two major ways to send push notifications to a flutter application without firebase.\n\nUsing flutter_local_notifications package send to notification locally\n\nexample code:\n @override\n void initState() {\n super.initState();\n var initializationSettingsAndroid = AndroidInitializationSettings('ypur-icon-name(icon)');\n var initializationSettingsIOS = IOSInitializationSettings();\n var initializationSettings = InitializationSettings(\n android: initializationSettingsAndroid, iOS: initializationSettingsIOS);\n flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin();\n flutterLocalNotificationsPlugin.initialize(initializationSettings,\n onSelectNotification: _onNotificationClicked);\n }\n\n Future _showNotification() async {\n var androidPlatformChannelSpecifics = AndroidNotificationDetails(\n 'Channel id', 'Your notification ID', 'Notification name',\n importance: Importance.defaultImportance,\n priority: Priority.defaultPriority);\n var iOSPlatformChannelSpecifics = IOSNotificationDetails();\n var platformChannelSpecifics = NotificationDetails(\n android: androidPlatformChannelSpecifics,\n iOS: iOSPlatformChannelSpecifics);\n await flutterLocalNotificationsPlugin.show(\n 0,\n 'Notification Alert 🔔',\n 'Message - There is a new notification on your account, kindly check it out',\n platformChannelSpecifics,\n payload:\n 'Message - There is a new notification on your account, kindly check it out',\n );\n }\n }\n\nThen you create a function or just show a dialog when the notification is clicked\ne.g\nFuture _onNotificationClicked() async {\n return showDialog();\n);\n\nAnd that for flutter local notification, you can check the package documentation for more info, another approach you can make use of is to connect this local notification to your database/server or API so it can be on call of your API that the user would receive the notification. etc\n\nOneSignal: is a free push notification service for mobile apps. This SDK makes it easy to integrate your Flutter iOS and/or Android apps with OneSignal and it's also used in powering mobile + web push, email, SMS & in-app messages.\n\nthe package is available on pub.dev - onesignal",
2021-06-29T09:23:44
yy