Google sign-in and notification settings in the Android app
Feature
Why it matters: In the Android app you can sign in with the Google account already on your phone, and set the phone up for notifications.
- Sign in with Google: the Android app’s sign-in page can show a “Continue with Google” button that uses the Google account on your phone, instead of a web sign-in page. It appears only in app versions that support it.
- Notifications on this phone: Settings in the app has a new row that shows whether notifications are on, lets you turn them on, and sends a test notification so you can check it works.
- Tapping a notification opens the matching page in the app, in the right tab.
A phone’s notification registration belongs to the signed-in session on it, so signing out, resetting your password or deleting your account removes it. Notifications from the site are switched on separately, so for now this mainly prepares the app for them.
Under the hood: each Google sign-in uses a one-time value issued when you tap the button, and the server checks the token Google returns against it before you’re signed in. Notifications arrive as data only, so the app builds each notification itself and checks the page it should open.
Commits (4)
-
ee28fd7M3: native Google sign-in for the Android app (server side) -
d6f27cdM3: push device registration, Settings notifications row, staging scrub -
543ec46M3: Android native Google sign-in, push registration and notification taps -
93494cdM3: Codex diff audit 1 fixes
Files Changed (62)
Gemfile | 5 + Gemfile.lock | 30 ++++ Makefile | 2 + android/.gitignore | 3 +- android/app/build.gradle.kts | 28 +++ android/app/google-services.json | 39 ++++ android/app/src/main/AndroidManifest.xml | 27 +++- .../java/com/norafoundry/eyeonmajors/AppRoutes.kt | 48 +++++- .../com/norafoundry/eyeonmajors/BaseActivity.kt | 43 ++++- .../eyeonmajors/EyeOnMajorsApplication.kt | 18 ++- .../eyeonmajors/GoogleSignInComponent.kt | 98 ++++++++++ .../NotificationPermissionComponent.kt | 72 ++++++++ .../eyeonmajors/NotificationTapActivity.kt | 36 ++++ .../norafoundry/eyeonmajors/PendingDeepLink.kt | 17 ++ .../norafoundry/eyeonmajors/PendingDestination.kt | 53 ++++++ .../eyeonmajors/PushMessagingService.kt | 69 +++++++ .../eyeonmajors/PushRegistrationComponent.kt | 48 +++++ .../norafoundry/eyeonmajors/SignedOutActivity.kt | 23 +++- .../com/norafoundry/eyeonmajors/TabsActivity.kt | 81 ++++++--- .../com/norafoundry/eyeonmajors/TokenDigest.kt | 16 ++ android/app/src/main/res/values/strings.xml | 1 + .../norafoundry/eyeonmajors/ActivityLaunchTest.kt | 11 +- .../com/norafoundry/eyeonmajors/AppRoutesTest.kt | 57 ++++++ .../eyeonmajors/NotificationTapTest.kt | 173 ++++++++++++++++++ .../eyeonmajors/PendingDestinationTest.kt | 70 ++++++++ .../norafoundry/eyeonmajors/TokenDigestTest.kt | 16 ++ android/build.gradle.kts | 1 + android/gradle/libs.versions.toml | 11 ++ app/controllers/concerns/authentication.rb | 1 + app/controllers/concerns/provider_sign_in_flow.rb | 83 +++++++++ .../native/google_sign_ins_controller.rb | 87 +++++++++- app/controllers/native/push_devices_controller.rb | 58 +++++-- .../native/test_notifications_controller.rb | 46 +++++ app/controllers/omniauth_callbacks_controller.rb | 72 +-------- app/helpers/native_app_helper.rb | 16 ++ .../bridge/google_sign_in_controller.js | 51 ++++++ .../bridge/notification_permission_controller.js | 24 +++ .../bridge/push_registration_controller.js | 38 ++++ app/jobs/application_push_notification_job.rb | 4 + app/models/application_push_device.rb | 23 +++ app/models/application_push_notification.rb | 15 ++ app/models/native_google_nonce.rb | 39 ++++ app/models/native_google_sign_in.rb | 16 ++ app/models/session.rb | 2 + app/views/native/_google_sign_in_button.html.erb | 23 +++ app/views/native/_notifications_card.html.erb | 20 +++ app/views/native/_push_registration.html.erb | 9 + .../shared/_hotwire_native_auth_state.html.erb | 3 + app/views/shared/_sign_in_options.html.erb | 4 + app/views/user_profiles/settings.html.erb | 1 + config/push.yml | 8 + config/routes.rb | 8 + .../201000000_create_action_push_native_devices.rb | 19 ++ db/schema.rb | 17 ++- docker-compose.production.yml | 10 ++ lib/tasks/push.rake | 17 ++ podman-compose.production.yml | 6 + podman-compose.staging.yml | 4 + scripts/load-staging-db.sh | 13 ++- test/integration/native_google_sign_in_test.rb | 299 ++++++++++++++++++++++++++++++ test/integration/native_push_devices_test.rb | 275 +++++++++++++++++++++++++++- .../application_push_device_concurrency_test.rb | 54 ++++++ 62 files changed, 2325 insertions(+), 136 deletions(-)