GithubHelp home page GithubHelp logo

goku-org / firebase_cloud_messaging_flutter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ottomandeveloper/firebase_cloud_messaging_flutter

0.0 0.0 0.0 20.4 MB

License: BSD 3-Clause "New" or "Revised" License

Dart 100.00%

firebase_cloud_messaging_flutter's Introduction

Send messages with Firebase Cloud Messaging from your dart backend!

Created using the HTTPv1 API of Firebase Cloud Messaging - you can find more on their Firebase Cloud Messaging API Docs.

Not affiliated in any way with the official Firebase team or Google. We just trying to help flutter & dart developers to send messages without using any external server.

Developer Contact Details

Usage

Settings > Service Accounts > Generate new key > Copy important informations directly from the created file or load it with FirebaseCloudMessagingServer( Your Service Account Content )

A simple usage example:

import 'package:firebase_cloud_messaging_flutter/firebase_cloud_messaging_flutter.dart';

void main() async {
  /// My Service Account Json File Content
  final serviceAccountFileContent = <String, String>{
    'type': '',
    'project_id': '',
    'private_key_id': '',
    'private_key': '',
    'client_email': '',
    'client_id': '',
    'auth_uri': '',
    'token_uri': '',
    'auth_provider_x509_cert_url': '',
    'client_x509_cert_url': ''
  };

  /// Add Your Service Account File Content as Map
  var server = FirebaseCloudMessagingServer(
    serviceAccountFileContent,
  );

  /// Get Firebase  Messagin Token [Optional, If you want to send message to specific user]
  /// Don't pass token if you want to send message to all registered users
  // String? token = await FirebaseMessaging.instance.getToken();

  /// Send a Message
  var result = await server.send(
    FirebaseSend(
      validateOnly: false,
      message: FirebaseMessage(
        notification: FirebaseNotification(
          title: 'Package by Ottoman',
          body: 'Ottoman added something new! ๐Ÿ”ฅ',
        ),
        android: FirebaseAndroidConfig(
          ttl: '3s',

          /// Add Delay in String. If you want to add 1 minute delat then add it like "60s"
          notification: FirebaseAndroidNotification(
            icon: 'ic_notification',
            color: '#009999',
          ),
        ),
        // token:
        //     token, // only required If you want to send message to specific user.
      ),
    ),
  );

  /// Print Request response
  print(result.toString());
}

Features and bugs

Please file feature requests and bugs at the Issue Tracker.

firebase_cloud_messaging_flutter's People

Contributors

dsyrstad avatar ottomandeveloper 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.