firebase_cloud_messaging_backend 1.0.1 icon indicating copy to clipboard operation
firebase_cloud_messaging_backend: ^1.0.1 copied to clipboard

Use Firebase Cloud Messaging in your dart server code

example/firebase_cloud_messaging_backend_example.dart

import 'package:firebase_cloud_messaging_backend/firebase_cloud_messaging_backend.dart';

class Example {
  String clientEmail = "The email address of the service account";
  String clientId = "The id of the client";
  String authKey =
      "Your private key - warning: confidential. Use the complete .pem like content";
  String privateKeyId = "Your private key id";
  String projectId = "Your project id";
  String token = "The token of the device/user you want to send a message to";

  void main() async {
    var server = FirebaseCloudMessagingServer(
        JWTClaim(
            client_email: "$clientEmail",
            client_id: "$clientId",
            private_key: authKey,
            private_key_id: "$privateKeyId"),
        "$projectId");

    var result = await server.send(Send(
        validate_only: false,
        message: Message(
            notification: Notification(
                title: "New content:", body: "John added something new!"),
            android: AndroidConfig(
                notification: AndroidNotification(
                    icon: "ic_notification", color: "#009999")),
            token: token)));
    print(result.successful);
  }
}
7
likes
85
pub points
1%
popularity

Publisher

verified publisher iconpdad.de

Use Firebase Cloud Messaging in your dart server code

Repository (GitHub)

Documentation

API reference

License

Icon for licenses.BSD-3-Clause (LICENSE)

Dependencies

googleapis_auth, http, json_annotation, json_serializable

More

Packages that depend on firebase_cloud_messaging_backend