Skip to content
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

Merged
merged 17 commits into from Jun 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
168cea1
[expo-notifications] Fix types and add web support for NotificationSc…
sjchmiela Jun 17, 2020
3ca7559
[expo-notifications] Fix types and add web support for NotificationsH…
sjchmiela Jun 17, 2020
1f4b6b1
[expo-notifications] Fix types and add web support for NotificationCh…
sjchmiela Jun 17, 2020
87bbf56
[expo-notifications] Fix types and add web support for NotificationCh…
sjchmiela Jun 17, 2020
e0f7852
[expo-notifications] Fix types and add web support for NotificationPe…
sjchmiela Jun 17, 2020
6f5324f
[expo-notifications] Rename NotificationPresenter to …Module
sjchmiela Jun 17, 2020
e2766e1
[expo-notifications] Fix types and add web support for NotificationPr…
sjchmiela Jun 17, 2020
ab425d6
[expo-notifications] Fix types and add web support for PushTokenManager
sjchmiela Jun 17, 2020
822e1ab
[expo-notifications] Fix types and add web support for NotificaitonSc…
sjchmiela Jun 17, 2020
a603e9a
[expo-notifications] Fix a copy-paste typo
sjchmiela Jun 17, 2020
7503801
[changelog] Add changelog entry
sjchmiela Jun 17, 2020
f277a24
[expo-notifications] Fix the warning message when adding a push token…
sjchmiela Jun 17, 2020
3b305b5
[expo-notifications] Swap web and native and provide empty fallback f…
sjchmiela Jun 18, 2020
836a491
[expo-notifications] Fix types and add non-supported fallback for get…
sjchmiela Jun 18, 2020
b925db5
[expo-notifications] Swap native and web for modules declarations
sjchmiela Jun 18, 2020
8d06db1
[expo-notifications] Fix types and add web support for NotificationsE…
sjchmiela Jun 18, 2020
066e841
[apps] Minor notifications related fixes
sjchmiela Jun 18, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions apps/native-component-list/src/screens/NotificationScreen.tsx
Expand Up @@ -138,7 +138,7 @@ export default class NotificationScreen extends React.Component<

_presentLocalNotificationAsync = async () => {
await this._obtainUserFacingNotifPermissionsAsync();
Notifications.scheduleNotificationAsync({
await Notifications.scheduleNotificationAsync({
content: {
title: 'Here is a scheduled notification!',
body: 'This is the body',
Expand All @@ -154,7 +154,7 @@ export default class NotificationScreen extends React.Component<

_LEGACY_presentLocalNotificationAsync = async () => {
await this._obtainUserFacingNotifPermissionsAsync();
Notifications.presentNotificationAsync({
await Notifications.presentNotificationAsync({
title: 'Here is a local notification!',
body: 'This is the body',
data: {
Expand All @@ -166,7 +166,7 @@ export default class NotificationScreen extends React.Component<

_scheduleLocalNotificationAsync = async () => {
await this._obtainUserFacingNotifPermissionsAsync();
Notifications.scheduleNotificationAsync({
await Notifications.scheduleNotificationAsync({
content: {
title: 'Here is a local notification!',
body: 'This is the body',
Expand Down
19 changes: 13 additions & 6 deletions apps/test-suite/tests/NewNotifications.js
Expand Up @@ -59,7 +59,7 @@ export async function test(t) {
t.expect(tokenFromEvent).toEqual(tokenFromMethodCall);
});

t.fit('resolves when multiple calls are issued', async () => {
t.it('resolves when multiple calls are issued', async () => {
const results = await Promise.all([
Notifications.getDevicePushTokenAsync(),
Notifications.getDevicePushTokenAsync(),
Expand All @@ -69,7 +69,7 @@ export async function test(t) {
});

// Not running this test on web since Expo push notification doesn't yet support web.
const itWithExpoPushToken = ['ios', 'android'].includes(Platform.OS) ? t.fit : t.xit;
const itWithExpoPushToken = ['ios', 'android'].includes(Platform.OS) ? t.it : t.xit;
itWithExpoPushToken('fetches Expo push token', async () => {
let experienceId = undefined;
if (!Constants.manifest) {
Expand All @@ -86,8 +86,15 @@ export async function test(t) {
});

itWithExpoPushToken('resolves when mixed multiple calls are issued', async () => {
let experienceId = undefined;
if (!Constants.manifest) {
// Absence of manifest means we're running out of managed workflow
// in bare-expo. @exponent/bare-expo "experience" has been configured
// to use Apple Push Notification key that will work in bare-expo.
experienceId = '@exponent/bare-expo';
}
await Promise.all([
Notifications.getExpoPushTokenAsync(),
Notifications.getExpoPushTokenAsync({ experienceId }),
Notifications.getDevicePushTokenAsync(),
]);
});
Expand Down Expand Up @@ -1304,7 +1311,7 @@ export async function test(t) {
};

t.beforeEach(async () => {
Notifications.cancelAllScheduledNotificationsAsync();
await Notifications.cancelAllScheduledNotificationsAsync();
Notifications.setNotificationHandler({
handleNotification: async () => {
timesSpyHasBeenCalled += 1;
Expand All @@ -1315,9 +1322,9 @@ export async function test(t) {
});
});

t.afterEach(() => {
t.afterEach(async () => {
Notifications.setNotificationHandler(null);
Notifications.cancelAllScheduledNotificationsAsync();
await Notifications.cancelAllScheduledNotificationsAsync();
});

t.it(
Expand Down
2 changes: 2 additions & 0 deletions packages/expo-notifications/CHANGELOG.md
Expand Up @@ -8,6 +8,8 @@

### 🐛 Bug fixes

- Fixed total incompatibility with the web platform – calling unsupported methods will now throw a readable `UnavailabilityError`. ([#8853](https://github.com/expo/expo/pull/8853) by [@sjchmiela](https://github.com/sjchmiela))

## 0.3.2 — 2020-06-10

### 🐛 Bug fixes
Expand Down
10 changes: 2 additions & 8 deletions packages/expo-notifications/build/BadgeModule.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/expo-notifications/build/BadgeModule.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions packages/expo-notifications/build/BadgeModule.native.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions packages/expo-notifications/build/BadgeModule.native.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/expo-notifications/build/BadgeModule.types.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions packages/expo-notifications/build/InstallationIdProvider.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.