| #
db1c4130 |
| 19-Jun-2020 |
Stanisław Chmiela <[email protected]> |
[expo-notifications] Add preliminary "support" for Web (#8853)
# 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 becaus
[expo-notifications] Add preliminary "support" for Web (#8853)
# 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).
show more ...
|
| #
cee2253d |
| 14-Jan-2020 |
Stanisław Chmiela <[email protected]> |
[expo-notifications] Device push token fetching module (#6577)
# Why
To eventually deprecate ExpoKit.
# How
- created a new unimodule, disabling autolinking in the root projects
- implemen
[expo-notifications] Device push token fetching module (#6577)
# Why
To eventually deprecate ExpoKit.
# How
- created a new unimodule, disabling autolinking in the root projects
- implemented `getDevicePushTokenAsync` method in TS, then in native (on iOS we rely on system framework, on Android we're using Firebase Cloud Messaging)
- implemented listening to token changes
### Notable changes to TS implementation
- I had to juggle around types a bit to achieve what I wanted — for TS to discriminate by `type: keyof Platform.OS` value what is the type of `data` field and at the same time to use `data: any` for unsupported platforms. Types are ready, but I needed to use [`@ts-ignore`](https://github.com/expo/expo/pull/6577/commits/0bd46874ad547f6a1f196adcfc15b6d98614d94f#diff-66b6995155cd1e190f53b012f5c2a857R43-R44) to get away with it.
### Notable changes to native implementation
- we use singleton module for listening to token changes [android](https://github.com/expo/expo/pull/6577/commits/69ee9efd42ba725703fd3f30073564ad3574f1d6#diff-5f9ef5ef7358f7a9c8cc386d42ee934f), [ios](https://github.com/expo/expo/pull/6577/commits/0aa2b66e1342c4de084fc329866752b53b4a6a76#diff-f8332f28b28ad9a24e0af0cb435876c7)
- on Android there's a service subclassing `FirebaseMessagingService` to which the singleton above subscribes [link](https://github.com/expo/expo/pull/6577/commits/69ee9efd42ba725703fd3f30073564ad3574f1d6#diff-b6817886a179022070e2417712503fa9)
### Notable changes to web implementation
- eventually, I guess, developers would want to customize how their app responds to notifications — for this I added a `serviceWorkerPath` manifest field [commit](https://github.com/expo/expo/pull/6577/commits/82e54aeb892b30661e0f5059e64acba70e686f85)
# Test Plan
- tests in `test-suite` are passing on **all three platforms** (on web puppeteer has to be run in head…ful (?) mode, otherwise overriding permissions doesn't work, which is a [known issue](https://github.com/puppeteer/puppeteer/issues/3279))
- push notifications sent to device push tokens are received on **all three platforms**
show more ...
|