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
[expo-notifications] Add preliminary "support" for Web #8853
Conversation
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.
looks great! thank you for standardizing this across the whole module 🙏
addListener: () => { | ||
if (!warningHasBeenShown) { | ||
console.warn( | ||
'[expo-notifications] Notifications handling is not yet fully supported on web. Handling notifications will have no effect.' |
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.
maybe just addListener: () => {}
for this one? this message seems specific to NotificationsHandlerModule
.
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.
Changed the warning message to
[expo-notifications] Listening to push token changes is not yet fully supported on web. Adding a listener will have no effect.
👍 Thank you for noticing this! 👁️
import { NotificationChannelGroupManager } from './NotificationChannelGroupManager.types'; | ||
|
||
export default { | ||
addListener: () => {}, |
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.
Lately we've been flipping the "web" and native extensions so empty shims like this are the default and things like .native
, .web
are used when a bundler that supports platform extensions is in use. In the future any other platform someone attempts to use would default to this empty unimplemented module as the default. Related #8502
…annelGroupManager
… change listener on web
…or other platforms
…ExpoPushToken and InstallationIdProvider
885daff
to
066e841
Compare
# Why Even though we don't support Web in `expo-notifications`, we don't want to be a pain to the users and throw errors just because of running the code on Web. # How Added simple object fallbacks for missing modules on web so that they are queryable by ```ts if (!Module.methodAsync) { throw new Unavailability… } ``` Swapped `.ts` + `.web.ts` for `.native.ts` + `.ts` (or + `.web.ts` + `.ts` where it made sense, eg. if we would need to use `localStorage` inside the `.ts` file I renamed it to `.web.ts` and added an empty fallback in `.ts`). # Test Plan - [x] Ran NCL in `bare-expo` on Web, clicked buttons around, noticed the error is readable and makes sense. - [x] Ran `expo-notifications` test-suite on both iOS and Web. It seems iOS tests are a little bit flaky, unfortunately (the errors could also happen due to erroring Expo API, HTTP error 504 when fetching push token, but I was able to make all of the tests pass just refreshing).
Hi, what are the plans regarding web support for notifications? I haven't found anything on the roadmap on canny.io. Thanks! |
Why
Even though we don't support Web in
expo-notifications
, we don't want to be a pain to the users and throw errors just because of running the code on Web.How
Added simple object fallbacks for missing modules on web so that they are queryable by
Swapped
.ts
+.web.ts
for.native.ts
+.ts
(or +.web.ts
+.ts
where it made sense, eg. if we would need to uselocalStorage
inside the.ts
file I renamed it to.web.ts
and added an empty fallback in.ts
).Test Plan
bare-expo
on Web, clicked buttons around, noticed the error is readable and makes sense.expo-notifications
test-suite on both iOS and Web. It seems iOS tests are a little bit flaky, unfortunately (the errors could also happen due to erroring Expo API, HTTP error 504 when fetching push token, but I was able to make all of the tests pass just refreshing).