Skip to content

gcm: support numeric sender registrations - #4

Open
iFixRobots wants to merge 2 commits into
mainfrom
codex/gcm-numeric-sender
Open

gcm: support numeric sender registrations#4
iFixRobots wants to merge 2 commits into
mainfrom
codex/gcm-numeric-sender

Conversation

@iFixRobots

Copy link
Copy Markdown

Problem

Numeric FCM sender IDs were registered as WebPush subscriptions, which Google rejects. Their pushes arrive with an app category instead of a subtype, leaving MessageEvent.AppID empty.

Fix

Use Chromium's extension registration format for numeric senders and read the category when a push has no subtype. Return registration errors explicitly so callers can handle failed requests.

Notes

Verified live registration and unregistration with Google. Captured Google Voice pushes carrying the registration ID in their category. go build ./... and go vet ./... pass.

Related: #3

@indent

indent Bot commented Sep 12, 2026

Copy link
Copy Markdown
PR Summary

Numeric FCM sender IDs (project numbers) were being registered with the WebPush format (app=org.chromium.linux + X-subtype=wp:<uuid>), which Google rejects; their pushes then arrived tagged with a category and no subtype, leaving MessageEvent.AppID empty. This PR registers numeric senders using Chromium's extension format and reads the category as a fallback, so numeric-sender registrations succeed and their AppID is populated. It also makes GCM registration/unregistration report failures explicitly instead of silently returning empty credentials.

  • gcm.go: add NewGCMAppID (numeric sender → 32-char ap Chromium extension id; otherwise wp:<UUID>) and setGCMAppID (extension ids use app=<id>; everything else keeps app=org.chromium.linux + X-subtype). The WebPush wire format is unchanged.
  • gcm.go: add parseGCMResponse to centralize response handling — non-200 status, an Error= body (typed GCMError), and a missing register token now return errors; unregister requires a token or deleted == appID.
  • gcm.go: fix the instance-id form field from appId to lowercase appid (matches real Chrome c2dm/register3 requests).
  • events.go: newMessageEvent falls back to data.GetCategory() when the subtype-derived AppID is empty.
  • errors.go: add the GCMError string type and the exported ErrGCMDeviceRegistration (PHONE_REGISTRATION_ERROR) constant so callers can detect registration errors.

Issues

No issues found.

CI Checks

All CI checks passed on a65dba2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant