-
Notifications
You must be signed in to change notification settings - Fork 15
chore: upgrade expo and react native packages to their latest versions #926
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
Merged
kylemcd
merged 10 commits into
main
from
kyle-kno-12289-update-expo-example-app-in-javascript-sdk-to-latest-version
Apr 2, 2026
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7bcec90
chore: upgrade expo and react native packages to their latest versions
kylemcd dd79426
fix: manypkg fix
kylemcd 2e23b47
fix: use NotificationBehavior type from getNotificationsModule instea…
kylemcd 787c395
fix: avoid misleading permission warning when notifications module is…
kylemcd 4f156f7
test: add coverage for getNotificationsModule and utils push notifica…
kylemcd f5bb5e9
fix: use react-native-reanimated 4.x with react-native-worklets for R…
kylemcd c825bc9
test: add full coverage for getNotificationsModule require and catch …
kylemcd a7b0d50
fix: use tilde range for react-native-svg in published package depend…
kylemcd 695c454
fix: lockfile
kylemcd 3070cd1
chore: fix typo in changeset
kylemcd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| "@knocklabs/expo-example": minor | ||
| "@knocklabs/react-native": minor | ||
| "@knocklabs/expo": minor | ||
| --- | ||
|
|
||
| chore: upgrade expo and react native packages to their latest version, ensure expo go builds on android get the proper warning about deprecated notification support from expo, ensure expo-example app works as expected. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| import Constants, { ExecutionEnvironment } from "expo-constants"; | ||
| import type * as Notifications from "expo-notifications"; | ||
| import { Platform } from "react-native"; | ||
|
|
||
| /** | ||
| * The type of the expo-notifications module when successfully loaded. | ||
| */ | ||
| export type NotificationsModule = typeof Notifications; | ||
|
|
||
| // Type aliases derived from the expo-notifications namespace so that consumers | ||
| // access all expo-notifications types through this module rather than importing | ||
| // from the package directly (which can trigger runtime side-effects). | ||
| export type Notification = Notifications.Notification; | ||
| export type NotificationResponse = Notifications.NotificationResponse; | ||
| export type NotificationBehavior = Notifications.NotificationBehavior; | ||
|
|
||
| /** | ||
| * Lazily load the expo-notifications module. | ||
| * | ||
| * In Expo SDK 55+, `import * as Notifications from "expo-notifications"` triggers | ||
| * a top-level side-effect (DevicePushTokenAutoRegistration.fx.ts) that calls | ||
| * `addPushTokenListener()`, which throws on Android Expo Go where push notification | ||
| * functionality has been removed (since SDK 53). | ||
| * | ||
| * We detect Android Expo Go before attempting the require() and skip it entirely, | ||
| * since the throw from expo-notifications bypasses JavaScript try/catch via | ||
| * React Native's global error handler. | ||
| * | ||
| * On all other environments (iOS Expo Go, development builds, production), | ||
| * expo-notifications loads normally. | ||
| */ | ||
|
|
||
| // Cache the module after the first load to avoid repeated require() calls and | ||
| // environment detection checks on every access. The three states are: | ||
| // undefined = not yet loaded (initial) | ||
| // null = unavailable (Android Expo Go or load failure) | ||
| // module = successfully loaded | ||
| let cachedModule: NotificationsModule | null | undefined = undefined; | ||
|
|
||
| function isAndroidExpoGo(): boolean { | ||
| return ( | ||
| Platform.OS === "android" && | ||
| Constants.executionEnvironment === ExecutionEnvironment.StoreClient | ||
| ); | ||
| } | ||
|
|
||
| // Abstracted for testability — Vitest cannot intercept require() calls | ||
| // inside dynamically imported modules after vi.resetModules(). | ||
| /* v8 ignore next 3 -- default require is replaced in tests via _resetForTesting */ | ||
| let requireNotifications: () => NotificationsModule = () => | ||
| // eslint-disable-next-line @typescript-eslint/no-require-imports | ||
| require("expo-notifications") as NotificationsModule; | ||
|
|
||
| export function getNotificationsModule(): NotificationsModule | null { | ||
| if (cachedModule !== undefined) { | ||
| return cachedModule; | ||
| } | ||
|
|
||
| if (isAndroidExpoGo()) { | ||
| console.warn( | ||
| "[Knock] Push notifications (remote notifications) are not available in Expo Go " + | ||
| "on Android. This is an Expo platform limitation — push notification support was " + | ||
| "removed from Expo Go on Android in SDK 53. Push features (token registration, " + | ||
| "notification listeners) will be disabled, but all other Knock features will " + | ||
| "continue to work.\n\n" + | ||
| "To use push notifications on Android, use a development build instead of Expo Go: " + | ||
| "https://docs.expo.dev/develop/development-builds/introduction/", | ||
| ); | ||
| cachedModule = null; | ||
| return cachedModule; | ||
| } | ||
|
|
||
| try { | ||
| cachedModule = requireNotifications(); | ||
| } catch { | ||
| console.warn( | ||
| "[Knock] expo-notifications could not be loaded. " + | ||
| "Push notification features will be disabled.", | ||
| ); | ||
| cachedModule = null; | ||
| } | ||
|
|
||
| return cachedModule; | ||
| } | ||
|
|
||
| /** | ||
| * @internal Test-only — reset the cached module and optionally override | ||
| * the require function used to load expo-notifications. | ||
| */ | ||
| export function _resetForTesting( | ||
| overrideRequire?: () => NotificationsModule, | ||
| ): void { | ||
| cachedModule = undefined; | ||
| if (overrideRequire) { | ||
| requireNotifications = overrideRequire; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this have a version check as well? E.g. checking the package version that they're running or the android device version?