Skip to content

notif: Use live value for app ID on registering APNs token #1451

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AhmedTareek
Copy link

@AhmedTareek AhmedTareek commented Mar 31, 2025

Fixes #407

Changes made:

  • Replaced the hardcoded app bundle ID with packageInfo.packageName.
  • Added a new test that sets a specific appId via packageInfo and confirms it’s used in a notification request.

The first change caused the "token initially unknown" test in store_test.dart to fail due to the added asynchronous call to ZulipBinding.instance.packageInfo, which delayed the completion of registerToken.

To resolve this, a flushMicrotasks was added after await startFuture in the test to ensure _registerNotificationToken completes before the test checks for the request.

@AhmedTareek AhmedTareek marked this pull request as ready for review April 1, 2025 13:04
@gnprice
Copy link
Member

gnprice commented Apr 2, 2025

Thanks for the contribution!

Before we can review this in detail, it will need tests. See the guidance in our README file about writing tests.

@gnprice gnprice added the maintainer review PR ready for review by Zulip maintainers label Apr 2, 2025
@AhmedTareek
Copy link
Author

Tests are added.

Copy link
Member

@rajveermalviya rajveermalviya left a comment

Choose a reason for hiding this comment

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

Thanks for working on this @AhmedTareek! Some comments below.

Copy link
Member

@rajveermalviya rajveermalviya left a comment

Choose a reason for hiding this comment

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

Thanks for the revision @AhmedTareek! Some nits otherwise looks good, moving to integration review from Greg.

@rajveermalviya rajveermalviya added integration review Added by maintainers when PR may be ready for integration and removed maintainer review PR ready for review by Zulip maintainers labels Apr 14, 2025
@rajveermalviya rajveermalviya requested a review from gnprice April 14, 2025 17:14
Copy link
Member

@gnprice gnprice left a comment

Choose a reason for hiding this comment

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

Thanks @AhmedTareek for picking this up, and @rajveermalviya for the previous reviews! Comments below.

@@ -149,9 +149,10 @@ class NotificationService {
await addFcmToken(connection, token: token);

case TargetPlatform.iOS:
const appBundleId = 'com.zulip.flutter'; // TODO(#407) find actual value live
Copy link
Member

Choose a reason for hiding this comment

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

nit in commit message:

Fixes zulip#407

follow existing patterns for how to format this — use git log (better, git log --grep Fixes) to see examples

Copy link
Member

Choose a reason for hiding this comment

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

notif: Use live value for app ID on registering APNs token

Fixes #407

Closer, but make it a complete sentence:

notif: Use live value for app ID on registering APNs token

Fixes #407.

@AhmedTareek AhmedTareek force-pushed the #407 branch 2 times, most recently from f1ee1ef to 09a1c01 Compare April 16, 2025 21:51
@AhmedTareek AhmedTareek requested a review from gnprice April 16, 2025 21:54
Copy link
Member

@gnprice gnprice left a comment

Choose a reason for hiding this comment

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

Thanks for the revision! This is close to merge — various small comments below.

@@ -149,9 +149,10 @@ class NotificationService {
await addFcmToken(connection, token: token);

case TargetPlatform.iOS:
const appBundleId = 'com.zulip.flutter'; // TODO(#407) find actual value live
Copy link
Member

Choose a reason for hiding this comment

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

notif: Use live value for app ID on registering APNs token

Fixes #407

Closer, but make it a complete sentence:

notif: Use live value for app ID on registering APNs token

Fixes #407.

Fixes zulip#407.

`await ZulipBinding.instance.packageInfo` was added to get the
packageName, making `registerToken` take longer to complete.
Previously, in "token initially unknown" test in the
UpdateMachine.registerNotificationToken `start()` and
`_registerNotificationToken()` finished in sync with the test’s
expectations. Now, `flushMicrotasks` is added to ensure that the
listener callback `_registerNotificationToken()` finishes its
async work before continuing the test.

Added packageInfo function in `example_data.dart` and updated tests
that implicitly relied on packageInfo data to explicitly set it.
@gnprice
Copy link
Member

gnprice commented Apr 23, 2025

Thanks @AhmedTareek for the revision! These changes all look good.

Before merging, I'd like to manually test this end to end, to check that notifications still work as expected. I believe they should — but the changes this PR is making are the kind where an oversight could easily cause notifications to totally break, and without manual testing we likely wouldn't learn that until it went out in the next release.

I tried doing that manual testing just now, but it seems like the instructions we've previously had for manually testing notification changes aren't currently working. So some debugging will be required to work out how to update them. (We'll need that sort of testing to be working again for other changes too, not only this PR.) I started a chat thread for that here:
#mobile-team > notifications from dev server @ 💬

Once that's sorted out, I can do a round of manual testing on this PR; and provided that comes out clean as expected, we'll then be able to merge it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration review Added by maintainers when PR may be ready for integration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

notif: Use live value for app ID on registering APNs token
3 participants