...........................................................................................................................................................................................................................................................................................
For those who have faintest idea about OneSignal, no worries you are reading the correct stuff…
OneSignal Account if you do not already have one.
OneSignal App ID, available in Keys & IDs
Before setting up, you must generate the appropriate credentials for the platform(s) you are releasing on:
iOS — Generate an iOS Push Certificate
Android — Generate a Google Server API Key
Create a Firebase Project.
Get your Firebase Cloud Messaging token and Sender ID..
2.1 Click the Gear icon in the top left and select “Project settings”.
2.2 Select the “CLOUD MESSAGING” tab.
2.3 Check the red sections:
You’ll need your Server key and Sender ID.
3. Configure your OneSignal app’s Android platform settings
3.1 Go to Settings and press the Configure button to the right of Google Android.
Paste your Server Key and Sender ID in here and press Save.
https://documentation.onesignal.com/docs/android-sdk-setup
Open your app/build.gradle (Module: app) file, add the following to the very top.
Add the following to your dependencies section.
Add the following in your android > defaultConfig section.
Update PUT YOUR ONESIGNAL APP ID HERE with your OneSignal app id
nstall the flutter package….
https://pub.dartlang.org/packages/onesignal
and import 'package:onesignal/onesignal.dart';
OneSignal.shared.init("your_app_id_here");
//in case of iOS --- see below
OneSignal.shared.init("your_app_id_here", {
OSiOSSettings.autoPrompt: false,
OSiOSSettings.inAppLaunchUrl : true
});
OneSignal.shared.setNotificationReceivedHandler((OSNotification notification) {
// will be called whenever a notification is received
});
OneSignal.shared.setNotificationOpenedHandler((OSNotificationOpenedResult result) {
// will be called whenever a notification is opened/button pressed.
});
For Creating notifications, use OSCreateNotification() and to send OneSignal.shared.postNotification(notification);
You need to have subscribed users before sending push messages, do that by clicking the Prompt for Push permission button in the app above
Go to OneSignal Dashboard, of your app
DASHBOARD
Click on Messages…and New Push..
Create message and at the end click on confirm. It will show you a pop-up for confirmation. Click Send Message
Woo hoo!!!!!! You can see the notification…