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

[notifications] Export NotificationPermissions.types #8747

Merged
merged 6 commits into from
Jun 26, 2020

Conversation

brentvatne
Copy link
Member

Why

This example code from the README currently results in [TypeError: undefined is not an object (evaluating 'Notifications.IosAuthorizationStatus.PROVISIONAL')]:

import * as Notifications from 'expo-notifications';

export async function allowsNotificationsAsync() {
  const settings = await Notifications.getPermissionsAsync();
  return (
    settings.granted || settings.ios?.status === Notifications.IosAuthorizationStatus.PROVISIONAL
  );
}

How

Exported NotificationPermissions.types from index.ts and added a simple check to verify that Notifications.IosAuthorizationStatus is defined when importing from expo-notifications entry point to prevent regression in the future.

Test Plan

Run test included in PR, run the code provided in the "Why" section above.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 9, 2020

Native Component List for this branch is ready

Copy link
Contributor

@sjchmiela sjchmiela left a comment

Choose a reason for hiding this comment

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

Thank you very much! Would you care to add a changelog entry for this, please? 🙏

Copy link
Contributor

@sjchmiela sjchmiela left a comment

Choose a reason for hiding this comment

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

10q! 🙏

@sjchmiela sjchmiela merged commit 9ac49fe into master Jun 26, 2020
@sjchmiela sjchmiela deleted the @brent/export-notification-permissions-types branch June 26, 2020 08:13
@hassey13
Copy link

hassey13 commented Jul 23, 2020

Whats the fix for this? I have this issue currently.

@bensalilijames
Copy link
Contributor

Could do this in the meantime:

import * as Notifications from "expo-notifications";
import { IosAuthorizationStatus } from "expo-notifications/build/NotificationPermissions.types";

export async function allowsNotificationsAsync() {
  const settings = await Notifications.getPermissionsAsync();
  return (
    settings.granted || settings.ios?.status === IosAuthorizationStatus.PROVISIONAL
  );
}

@brentvatne
Copy link
Member Author

@hassey - this should be included in the latest release, at the time of writing expo-notifications@0.6.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants