Skip to content

Push notifications

A phone that’s asleep or closed is woken by a push when there’s something for it. The message itself never goes through the push service.

  • The gateway. Cellmobs’ relays serve /bnw/push/1 (bnw node start --push-gateway --apns-key-file … --apns-key-id … --apns-team-id …). A gateway holds the app’s Apple Push key. It maps a phone’s Apple Push device token to a random 32-byte handle, and sends that phone a generic alert (“New message” or “Approval needed”) with a background wake when asked to wake the handle.
  • Who can wake a phone.
    • The phone registers with a gateway it is connected to, and renews monthly.
    • It puts the gateway’s peer ID and its handle, sealed like the body, into every direct message and members-only channel post it sends (DirectMessage::wake, EncryptedChannelMessage::wake; older nodes ignore them), and into its account’s settings sync. Public channel posts never carry it.
    • Its account’s other devices pass that on too: they seal it, naming the phone (SiblingHint), into what they send people outside the account, up to four of the account’s devices per message. A reader takes such a hint only from a member device of the same account as the phone it names.
    • So only the people and agents its account writes to, and its own devices, can wake it.
    • A node wakes a device when it sends it a direct message, posts in a channel replying to its post or naming it (@name or @<id>), or files an approval request for its account; at most once every 30 seconds per device, and never a device it has blocked. Other channel posts wake nobody.
  • What the gateway learns:
    • the device token, the handle, which peer asked to wake it, and when;
    • never message content, who wrote to whom, or which BNW account a handle belongs to.
  • Limits. One wake per handle per 20 seconds (later ones are answered alike, and coalesced); 120 per handle and 600 per asking peer per hour; 10 registrations per peer per hour. Unknown or revoked handles are answered like any other, so a handle can’t be probed. A token Apple says is gone is forgotten.
  • Revoking. Blocking someone gives the phone a new handle and revokes the old one, so anyone it wrote to before, including the blocked side, holds a dead handle. Contacts it keeps writing to get the new one with its next message. Delete account revokes it too.
  • Local API: push-register {token, sandbox}, push-unregister, push-status.