Skip to content

Commit 0b55a86

Browse files
dadachiclaude
andauthored
Document push notification setup (#76)
Add a Push Notifications section to CLAUDE.md (provider-name platform enum, models, notifier config gotchas, credentials layout, APNs sandbox/production matching). Advertise push in the README feature lists (noticed + action_push_native, and an Included Features entry noting it's paid-clients only) plus a one-line credentials pointer in Initial Setup. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 2f25ffd commit 0b55a86

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

CLAUDE.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,16 @@ bin/rails dbconsole # Database console
8080
- Solid Cache for caching in production/staging
8181
- Monitor jobs at `/madmin/jobs` (Mission Control)
8282

83+
### Push Notifications
84+
Cross-platform push via the `noticed` (v3) and `action_push_native` gems. APNs for iOS, FCM for Android.
85+
86+
- **Provider names, not OS names**: the device `platform` is `apple` (APNs) or `google` (FCM) — never `ios`/`android`. The enum (`validate: true`) rejects anything else with 422 "Platform is not included in the list".
87+
- **Models**: `ApplicationPushDevice < ActionPushNative::Device` (`action_push_native_devices` table; polymorphic `owner`, unique on `[platform, token]`). `ApplicationPushNotification < ActionPushNative::Notification`. Delivery records live in `noticed_events` / `noticed_notifications`. All visible in `/madmin`.
88+
- **Device registration**: `POST /api/v1/shopkeeper/devices` is idempotent on `(platform, token)` — re-POST updates `last_active_at`; a token bound to another shopkeeper is reassigned.
89+
- **Notifiers**: subclass `ApplicationNotifier` (`Noticed::Event`). `ItemTagNotifier` fires from the AASM `complete` event. In `deliver_by :action_push_native`, the `with_apple`, `with_google`, and `with_data` options must each return a **Hash** (use `{}` when empty) — passing `nil` raises `TypeError: no implicit conversion of nil into Hash`.
90+
- **Config & secrets**: `config/push.yml` reads everything from credentials (`bin/rails credentials:edit --environment <env>`) under `action_push_native:apns:{key_id, team_id, topic, encryption_key}` and `action_push_native:fcm:{project_id, encryption_key}`. APNs `encryption_key` is the full `.p8` PEM; FCM `encryption_key` is the entire service-account JSON. `topic` stays in credentials (not source) because the agent's rename pipeline would otherwise desync the bundle id.
91+
- **APNs sandbox vs production**: `connect_to_development_server: <%= Rails.env.development? %>`. The token's environment is fixed at iOS build time — Xcode debug builds get **sandbox** tokens, TestFlight/App Store get **production**. They must match the server: test Xcode debug builds against a **local development** server; use TestFlight to test against Render. A mismatch returns APNs `400 BadDeviceToken`, which the gem treats as `TokenError` and **destroys the device row** (the default `rescue_from`). FCM has no such split.
92+
8393
### Testing Strategy
8494
- Minitest for all tests (models, controllers, integration, policies)
8595
- WebMock for stubbing external HTTP requests

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ For more information, visit [nativeapptemplate.com](https://nativeapptemplate.co
2222
- **[pundit](https://github.com/varvet/pundit)**
2323
- **[acts_as_tenant](https://github.com/ErwinM/acts_as_tenant)**
2424
- **[pagy](https://github.com/ddnexus/pagy)**
25+
- **[noticed](https://github.com/excid3/noticed)** + **[action_push_native](https://github.com/basecamp/action_push_native)** (push notifications)
2526
- **Test** (Minitest)
2627

2728
### Included Features
@@ -39,6 +40,7 @@ For more information, visit [nativeapptemplate.com](https://nativeapptemplate.co
3940
- Force App Version Update
4041
- Force Privacy Policy Version Update
4142
- Force Terms of Use Version Update
43+
- Push Notifications (APNs for iOS, FCM for Android) — paid clients only
4244
- And more!
4345

4446
## Related Repositories
@@ -82,6 +84,8 @@ Run `bin/setup` to install Ruby and JavaScript dependencies and setup your datab
8284
bin/setup
8385
```
8486

87+
Push notifications (used by the paid iOS/Android clients) need APNs and FCM credentials. Add them per environment with `bin/rails credentials:edit --environment <env>` under `action_push_native:apns` and `action_push_native:fcm`; see `config/push.yml` for the expected keys.
88+
8589
## Running NativeAppTemplate API on your Wi-Fi
8690

8791
Copy `.env.sample` to `.env` and set `HOST` to your current Wi-Fi IP. On macOS: `ipconfig getifaddr en0`. `bin/dev` binds Rails to that address so the dev server is reachable from both the host browser and from any phone on the same network at `http://<wifi-ip>:3000`. When your Wi-Fi IP changes, update `HOST` here and the matching `NATIVEAPPTEMPLATE_API_DOMAIN` in the mobile apps (Xcode scheme for iOS, `~/.gradle/gradle.properties` for Android) — Rails fails loudly if `HOST` is unset, which keeps the three sides honest. Never use `127.0.0.1`, `localhost`, or `0.0.0.0`.

0 commit comments

Comments
 (0)