Quickstart
This guide uses your test environment, so nothing reaches real users and you don’t need a user token yet.
1. Create a project
Section titled “1. Create a project”In the dashboard, create a project for your app. It comes with a test and a live environment, and each has a publishable key for your app and a secret key for your server.
2. Upload your keys
Section titled “2. Upload your keys”Upload your Apple .p8 key and your Firebase service account. PushFleet checks both by minting a real token, so you know right away if something’s wrong. Apple and Android show where to find them.
3. Register a device
Section titled “3. Register a device”Call register from your app once the operating system gives you a push token. Use your test publishable key and your own ID for the signed-in user.
PushFleet.configure(publishableKey: "pf_pub_test_…")
PushFleet.register(deviceToken: token, userId: "user_8f3k")PushFleet.configure(context, publishableKey = "pf_pub_test_…")
PushFleet.register(fcmToken = token, userId = "user_8f3k")await PushFleet.configure(publishableKey: "pf_pub_test_…");
await PushFleet.register(userId: "user_8f3k");import PushFleet from "@pushfleet/react-native";
PushFleet.configure({ publishableKey: "pf_pub_test_…" });
await PushFleet.register({ userId: "user_8f3k" });In live mode the app also passes a user token your server signed. See identity verification.
4. Send
Section titled “4. Send”Send from your server with your test secret key. You address a user, not a device; PushFleet delivers to every device they’ve registered.
import { PushFleet } from "pushfleet";
const fleet = new PushFleet(process.env.PUSHFLEET_SECRET_KEY);
await fleet.send({
to: "user_8f3k",
title: "Your order shipped",
body: "Arriving Thursday",
});import os
from pushfleet import PushFleet
fleet = PushFleet(os.environ["PUSHFLEET_SECRET_KEY"])
fleet.send(
to="user_8f3k",
title="Your order shipped",
body="Arriving Thursday",
)fleet := pushfleet.New(os.Getenv("PUSHFLEET_SECRET_KEY"))
fleet.Send(ctx, pushfleet.SendParams{
To: "user_8f3k",
Title: "Your order shipped",
Body: "Arriving Thursday",
})let fleet = PushFleet::from_env()?;
fleet
.send()
.to("user_8f3k")
.title("Your order shipped")
.body("Arriving Thursday")
.await?;fleet = PushFleet::Client.new(ENV["PUSHFLEET_SECRET_KEY"])
fleet.push(
to: "user_8f3k",
title: "Your order shipped",
body: "Arriving Thursday"
)curl https://api.pushfleet.com/v1/send \
-H "Authorization: Bearer $PUSHFLEET_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{"to":"user_8f3k","title":"Your order shipped","body":"Arriving Thursday"}'The API answers 202 with the message’s ID right away, and delivery happens in the background:
{"id":"msg_2Xk9fQ","status":"queued"}Look the message up later to see its status on each device, or watch it arrive in the dashboard’s delivery log.