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

feat(expo-notifications): handle expo-notifications #10

Merged
merged 6 commits into from
Nov 24, 2022

Conversation

MSzalowski
Copy link

@MSzalowski MSzalowski commented Nov 16, 2022

Description

This pr introduces expo-notifications.

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • Test A
  • Test B

**For both tests copy Expo push token from application settings and paste it to: **
Zrzut ekranu 2022-11-16 o 16 40 38
in Expo Push Notification Tool - https://expo.dev/notifications

Test A

  1. Keep the application in the foreground (active) state.
  2. Fill in notification data in https://expo.dev/notifications and click Send a Notification.
  3. Notification should be received with the title Notification from foreground on an Alert.

Test B

  1. Keep the application in the background (inactive) state.
  2. Fill in notification data in https://expo.dev/notifications and click Send a Notification.
  3. Notification (from expo) should be displayed in an app - click on it.
  4. Notification in the active state should be displayed on the Alert with the title Notification from background.

Screenshot(s)

Foreground

IMG_ECC3F78BBF0E-1

Background

RPReplay_Final1668613998 (1)

Test Configuration:

  • Hardware:
    OS: macOS 12.6
    CPU: (8) arm64 Apple M1
    Memory: 194.66 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  • Phone: iPhone 14 Pro (iOS 16.1)

Checklist:

  • Add correct label to your pull request
  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@MSzalowski MSzalowski added the enhancement New feature or request label Nov 16, 2022
Copy link
Collaborator

@MateuszRostkowski MateuszRostkowski left a comment

Choose a reason for hiding this comment

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

Check my little suggestions, if you think it's not worth you can just merge it

Comment on lines 23 to 39
const { notification, setNotification } = useNotificationContext()

useEffect(() => {
const initNotifications = async () => {
await registerForPushNotificationsAsync()
}
initNotifications()
}, [])

useEffect(() => {
if (notification) {
Alert.alert('Notification', JSON.stringify(notification), [
{ text: 'Cancel', onPress: () => setNotification(undefined), style: 'cancel' },
{ text: 'Ok', onPress: () => setNotification(undefined) },
])
}
}, [notification, setNotification])
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe move it to seperate file, for example useNotificationsSetup, it will be easier to maintain it in the future


useEffect(() => {
if (notification) {
Alert.alert('Notification', JSON.stringify(notification), [
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe instead of displaying it in alert you can use react-native-notificated package that we have implemented.

It's just a proposition, maybe it will look better

@MateuszRostkowski MateuszRostkowski merged commit aec56a9 into main Nov 24, 2022
@MateuszRostkowski MateuszRostkowski deleted the feat/expo-notifications branch January 20, 2023 07:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants