Quickstart
From no account to a push on your phone, then sending from your server. About 15 minutes.
You need a paid Apple Developer Program membership, Xcode 16 or later, and an iPhone or iPad to test on. The Pushwren SDK supports iOS 16, iPadOS 16, Mac Catalyst 16 and macOS 13 and later.
1. Get an account
Pushwren is in private beta. Request access and we’ll email an invite. Then sign in to the portal with the invited address and accept the Terms.
2. Create your app in the portal
The portal’s setup starts with Create app: give the app a name and enter its bundle ID exactly as Xcode shows it (com.example.weather). Each app has its own keys, devices and delivery log.
3. Add your APNs key
Apple accepts a push only when it’s signed with a key from your Apple Developer account. In Add APNs key, choose your .p8 file, enter your Team ID (a 10-character code such as ABCDE12345), and click Upload key. Pushwren checks the key with Apple straight away and shows a result for sandbox and for production.
No key yet? Making an APNs key takes about five minutes.
4. Add the Swift package
- In Xcode, choose File › Add Package Dependencies…, paste
https://github.com/pushwren/pushwren-swift, choose Up to Next Minor Version (while the SDK is 0.x, a minor release may change its API), and add the Pushwren product to your app target. - Under Signing & Capabilities, add Push Notifications. Without it the device never gets a token.
- If you’ll send silent pushes, also add Background Modes and tick Remote notifications.
With Package.swift instead: .package(url: "https://github.com/pushwren/pushwren-swift", .upToNextMinor(from: "0.3.0")).
5. Configure Pushwren at launch
Configure Pushwren with your app’s publishable key (pk_live_…, shown in the setup and under Settings › API keys), and use Pushwren’s app delegate:
import Pushwren
import SwiftUI
@main
struct MyApp: App {
@UIApplicationDelegateAdaptor(PushwrenAppDelegate.self) var appDelegate
init() {
Pushwren.configure(appKey: "pk_live_...")
}
var body: some Scene { WindowGroup { ContentView() } }
}
On native macOS, use @NSApplicationDelegateAdaptor(PushwrenAppDelegate.self). configure registers the device with APNs straight away: a device token needs no permission. Ask for permission to show alerts where it fits your app:
let status = try await Pushwren.requestPermission()
PushwrenAppDelegate forwards the token, counts taps and shows banners while the app is open. The SDK never swizzles. If your app already has an app delegate, see If your app already has an app delegate.
6. Link devices to your users
To send to a person rather than a device, tell Pushwren who is signed in, after sign-in and at every launch while someone is signed in:
Pushwren.setUserID("u_123") // your database's ID for the user, not an email address
Pushwren.clearUserID() // on sign-out
Users and sign-out covers reinstalls, tags and deleting a device.
7. Run on a device
Run the app on your iPhone or iPad from Xcode. The setup’s Wait for a device step shows it as soon as it registers, with its environment: apps run from Xcode use sandbox, TestFlight and App Store builds use production. To see what the SDK knows on the device, print await Pushwren.diagnostics().
8. Send a test push
In Send a test push, choose Send test push. The device shows the notification, and the portal’s delivery log shows it as accepted: Apple took it. Apple never confirms that a device showed a push, so “accepted” is the most any service can tell you.
Nothing arrived? Troubleshooting lists what to check.
9. Send from your server
Make a secret key (sk_live_…) in the portal under Settings › API keys. A secret key can send to all your users, so keep it on your server and never put it in an app.
curl https://api.pushwren.com/v1/notifications \
-H "Authorization: Bearer $PUSHWREN_SECRET_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-A1001-shipped" \
-d '{
"target": { "userIds": ["u_123"] },
"alert": { "title": "Order shipped", "body": "Your order A1001 is on its way." },
"data": { "orderId": "A1001" }
}'
The answer is 202 Accepted with the notification’s id. Retry a connection error or a 5xx with the same Idempotency-Key and it sends once. Notifications covers targets, scheduling, silent pushes and reading results.
To keep an order or a game on the Lock Screen and update it from your server, see Live Activities.