Skip to content

Push notification token management#5178

Open
dgboss wants to merge 34 commits intomainfrom
task/fcm-tokens/4906
Open

Push notification token management#5178
dgboss wants to merge 34 commits intomainfrom
task/fcm-tokens/4906

Conversation

@dgboss
Copy link
Collaborator

@dgboss dgboss commented Mar 2, 2026

  • Uses @capacitor-firebase/messaging instead of @capacitor/push-notifications as it simplifies token handling (ie. no need to handle FCM and APNs tokens separately)
  • Uses @capacitor/device to get unique device id for storage of fcm tokens
  • Android and iOS boilerplate to prompt user to allow push notifications
  • DB table for token tracking
  • CRUD ops for token management

Will require local copies of mobile/asa-go/ios/App/App/GoogleService-Info.plist and mobile/asa-go/android/app/google-services.json for iOS and Android builds respectively.

When we implement the sending of push notifications we will need to also implement deactivating unregistered tokens.

Closes: #4906

Test Links:

Landing Page
MoreCast
Percentile Calculator
C-Haines
FireCalc
FireCalc bookmark
Auto Spatial Advisory (ASA)
HFI Calculator
SFMS Insights
Fire Watch

@codecov
Copy link

codecov bot commented Mar 3, 2026

Codecov Report

❌ Patch coverage is 77.95276% with 28 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.29%. Comparing base (0d95074) to head (d9ff808).

Files with missing lines Patch % Lines
mobile/asa-go/src/App.tsx 30.76% 7 Missing and 2 partials ⚠️
mobile/asa-go/src/api/pushNotificationsAPI.ts 0.00% 6 Missing ⚠️
...ile/asa-go/src/services/pushNotificationService.ts 85.71% 4 Missing and 1 partial ⚠️
backend/packages/wps-api/src/app/routers/fcm.py 90.90% 2 Missing and 1 partial ⚠️
mobile/asa-go/src/hooks/usePushNotifications.ts 81.25% 3 Missing ⚠️
mobile/asa-go/src/slices/authenticationSlice.ts 83.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5178      +/-   ##
==========================================
+ Coverage   68.80%   69.29%   +0.49%     
==========================================
  Files         392      463      +71     
  Lines       16373    17803    +1430     
  Branches     1846     2071     +225     
==========================================
+ Hits        11265    12337    +1072     
- Misses       4527     4820     +293     
- Partials      581      646      +65     
Flag Coverage Δ
asa_go 74.36% <69.51%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dgboss dgboss requested review from brettedw and conbrad March 3, 2026 22:48
@dgboss dgboss requested a review from conbrad March 4, 2026 16:18
:param device_token: The record to be saved.
:type device_token: DeviceToken
"""
session.add(device_token)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I test this in ASA Go on my iphone, I noticed that if I close the app then open it again, I get a new record stored with a different token each time. Maybe there's something I don't understand about these tokens.....is that expected?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should be using this with a device_id column as well, for upserting tokens: https://capacitorjs.com/docs/apis/device#getid

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strange, I definitely don't see that on Android! The fcm token for my phone survives app re-starts, phone re-starts and app re-installs. I'll explore upserting as you suggested.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 2664f47 and fcb8a26

@dgboss dgboss requested a review from brettedw March 5, 2026 22:06
Copy link
Collaborator

@conbrad conbrad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 6, 2026

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ASA Go: Notifications & Device Tracking

3 participants