Giter VIP home page Giter VIP logo

push_notification's Introduction

Read:
1- Create the flutter project // flutter create example
2- Install firebase cli and login from https://firebase.google.com/docs/cli?hl=en&authuser=1#install_the_firebase_cli
3- Create the firebase project and create firebase flutter app from firebase dashboard
4- Run dart pub global activate flutterfire_cli
5- Run flutterfire configure --project=projectname // or get the full command from firebase create flutter instructions.
6- Run flutter pub add firebase_core & flutter pub add firebase_messaging.
7- Add this to your main.dart file:
import 'package:firebase_core/firebase_core.dart';
import 'firebase_options.dart';

FirebaseMessaging messaging = FirebaseMessaging.instance;

@pragma('vm:entry-point')
Future _firebaseMessagingBackgroundHandler(RemoteMessage message) async {}

void main async () {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
NotificationSettings settings = await messaging.requestPermission(
alert: true,
announcement: false,
badge: true,
carPlay: false,
criticalAlert: false,
provisional: false,
sound: true,
);

FirebaseMessaging.onMessage.listen((RemoteMessage message) {});
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
await messaging.subscribeToTopic("allDevices");
}
8- Open up the apple developer menu and follow this guide: https://firebase.flutter.dev/docs/messaging/apple-integration/
9- Run the node server and start sending json post requests using any client like postman in this structure:
{
"message": "yourmessage"
} // Request Body.
10- You should receive the notification on your device.
Note this only works on real devices not simulators.

push_notification's People

Contributors

shawket4 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.