Different Requests

Push notifications

Your own Apple key signs the push, so a notification comes from you.

Somebody who follows a request gets a notification when it changes. The push is signed with your own Apple key, so it comes from you — Apple accepts a notification for your bundle id only when it is signed by the team that owns it, so there is no key of ours that could do it.

Upload your key

In Apple's developer portal, make a key with Apple Push Notifications enabled and download the .p8 file. Apple lets you download it once. Then open your app's Push screen here and upload it, with its key id, your team id and your bundle id.

The Push screen is in the console, once you have an account.

We store it encrypted and never show it again. That one is a real secret: it signs pushes for every app under your Apple team and does not expire until you revoke it.

Register the device on every launch

A token changes on reinstall and Apple can invalidate one silently, so this is something you do at every launch rather than once.

func application(
  _ application: UIApplication,
  didRegisterForRemoteNotificationsWithDeviceToken tokenData: Data
) {
  Task {
    do {
      let registered = try await requests.client.registerDevice(
        tokenData: tokenData,
        environment: .production
      )
      logger.info("DifferentRequests: device \(registered.device.id)")
    } catch {
      logger.error("DifferentRequests: \(error.localizedDescription)")
    }
  }
}

State the environment yourself. A token minted by a debug build is a sandbox token, and pushing a sandbox token to production fails with nothing useful to read. Use .sandbox in debug builds and .production in what you ship.

Signing somebody out

unregisterDevice(deviceID:) drops a device. Call it when a person signs out of your app.

What a failed push does

Nothing, to your caller. A push that cannot be delivered never fails a call — the person still sees the change in the inbox next time they open it.