-
Notifications
You must be signed in to change notification settings - Fork 2
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
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.
Check my little suggestions, if you think it's not worth you can just merge it
src/navigation/RootNavigator.tsx
Outdated
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]) |
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 move it to seperate file, for example useNotificationsSetup
, it will be easier to maintain it in the future
src/navigation/RootNavigator.tsx
Outdated
|
||
useEffect(() => { | ||
if (notification) { | ||
Alert.alert('Notification', JSON.stringify(notification), [ |
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 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
Description
This pr introduces expo-notifications.
Type of change
How Has This Been Tested?
**For both tests copy Expo push token from application settings and paste it to: **
in Expo Push Notification Tool - https://expo.dev/notifications
Test A
Send a Notification
.Notification from foreground
on an Alert.Test B
Send a Notification
.Notification from background
.Screenshot(s)
Foreground
Background
Test Configuration:
OS: macOS 12.6
CPU: (8) arm64 Apple M1
Memory: 194.66 MB / 16.00 GB
Shell: 5.8.1 - /bin/zsh
Checklist: