Get Notified the Moment Someone Installs Your SwiftUI App
Your analytics dashboard will tell you how many installs you got — eventually. You'll check it tomorrow morning, or maybe the day after, and see a number. That number will have no emotional weight.
There's a better way: feel it happen in real time.
The idea
Pushmark is a free iOS app that receives push notifications triggered by a simple HTTP POST. Install it on your phone, create a channel, and anything that can make an HTTP request can notify you — including your own apps. On first launch, your app fires a single POST to that channel, and your phone buzzes instantly. No backend, no APNs certificates, no provisioning headaches.
Setup
- Download Pushmark on your iPhone
- Create a channel — give it a name like "MyApp installs"
- Copy the channel hash from the channel detail page
SwiftUI implementation
Replace YOUR_CHANNEL_HASH with the hash you just copied, then add a notifyInstall() function and call it from your root view's .onAppear modifier:
import SwiftUI
@main
struct MyApp: App {
var body: some Scene {
WindowGroup {
ContentView()
.onAppear { notifyInstall() }
}
}
}
func notifyInstall() {
let defaults = UserDefaults.standard
let key = "hasLaunchedBefore"
guard !defaults.bool(forKey: key) else { return }
// Flag set before the network call (fire-and-forget — no retry on failure)
defaults.set(true, forKey: key)
let channelHash = "YOUR_CHANNEL_HASH"
let url = URL(string: "https://api.pushmark.app/\(channelHash)")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
let locale = Locale.current.identifier
let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "unknown"
let appName = Bundle.main.infoDictionary?["CFBundleName"] as? String ?? "App"
let body: [String: Any] = [
"message": [
"app": appName,
"version": version,
"locale": locale
],
"type": "success"
]
request.httpBody = try? JSONSerialization.data(withJSONObject: body)
URLSession.shared.dataTask(with: request).resume()
}
The .onAppear modifier runs once when the root view appears. The UserDefaults flag ensures it only fires on the very first launch.
That's it. The next time someone opens your app for the first time, you'll feel your phone buzz.
Richer notifications
The message object is freeform. Include whatever context matters to you:
let body: [String: Any] = [
"message": [
"app": appName,
"version": version,
"locale": Locale.current.regionCode ?? "??",
"timezone": TimeZone.current.identifier
],
"type": "success"
]
Common fields to add:
Locale.current.regionCode— country (e.g.US,DE,JP)Locale.current.identifier— full locale (e.g.en_US)TimeZone.current.identifier— timezoneBundle.main.infoDictionary?["CFBundleShortVersionString"]— app version
Why Pushmark
Getting push notifications to your device from an iOS app normally requires a server with APNs credentials, a provider token or certificate, and a registered push token from the target device. That's the right setup for production apps sending notifications to users.
This pattern is for a different case: you want to notify yourself, and you want zero infrastructure. Pushmark handles the APNs side. Your app just makes an HTTP POST.
See the Getting Started guide for the full API reference.