-
Notifications
You must be signed in to change notification settings - Fork 508
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(Mobile): add notifications opt-In screen #4837
Conversation
Branch preview✅ Deploy successful! Storybook: |
Coverage (43%)
|
jest.mock('@notifee/react-native', () => ({ | ||
AndroidImportance: { | ||
NONE: 0, | ||
MIN: 1, | ||
LOW: 2, | ||
DEFAULT: 3, | ||
HIGH: 4, | ||
}, | ||
})) | ||
|
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.
I guess that we should move this to a global mock as you have it also in the Onboarding.container.test.tsx?
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.
moved.
@@ -17,6 +18,9 @@ const styles = StyleSheet.create({ | |||
signing: { | |||
height: Math.abs(windowHeight * 0.3), | |||
}, | |||
notifications: { | |||
height: Math.abs(windowHeight * 0.32), |
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.
what's up with those magic contants here? For signing it is 0.3, here it is 0.32? Why are we multiplying with that? How does it look on a smaller/bigger device?
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.
rolledback since the whole implementation wasn't supposed to be on onboarding flow.
@@ -55,6 +57,11 @@ const useNotifications = (): NotificationsProps => { | |||
if (isAppNotificationEnabled) { | |||
dispatch(toggleAppNotifications(false)) | |||
} | |||
|
|||
if (isOnboarding) { | |||
router.navigate('/(tabs)') |
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.
I think that we should be using replace instead of navigate. With navigate on devices with a hardware back button you would be able to go bath to the onboarding screeen. Where with replace you won't be.
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.
Good catch.
@Jonathansoufer could you please adjust the PR title as per our guidelines? |
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.
What is the plan with this screen? When are we going to show it? Immediately after the user goes through the onboarding or at a later stage? After that if the user cancels are we prompting him every time?
const { isAppNotificationEnabled, promptAttempts } = useNotifications() | ||
const dispatch = useAppDispatch() | ||
const router = useRouter() | ||
|
||
/* | ||
* If the user has not enabled notifications and has not been prompted to enable them, | ||
* redirect to the opt-in screen | ||
* */ | ||
|
||
const shouldShowOptIn = !isAppNotificationEnabled && !promptAttempts | ||
|
||
useEffect(() => { | ||
if (shouldShowOptIn) { | ||
dispatch(updatePromptAttempts(1)) | ||
router.navigate('/notifications-opt-in') | ||
} | ||
}, []) |
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.
This is weird. The AssetsContainer should not care about notifications.
Get some inspiration from here:
https://docs.expo.dev/router/reference/authentication/
https://reactnavigation.org/docs/auth-flow
I think that the _layout.tsx should be the place where we decide what first screen we show to the user.
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.
I completely get your point here, but we don't wanna spam our users before the Onboarding, and if we use _layout, this takes place before anything. The other alternative would be calling it at HomeScreen, wdyt?
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.
When the user clicks on "get started/continue" in the onboarding flow we should set a flag "onboarding_done": true. Next time the user starts we should not show the onboarding screens. So we will be deciding in the _layout.tsx which screen to show anyway.
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.
Jonathan and I, agreed to merge this PR as is, but create a follow up Ticket that would move the logic of the first screen to the _layout or to a better place.
What it solves
This ticket implements the notifications onboarding screen, enabling users to toggle the feature ON or deciding to leave for later. Its important to mention though that after three rejected attempts the user will not be prompt again within a month.
P.S: Although out of the scope of this PR, it was implemented a reusable FloatingContainer which is intent to be used to group and stick elements on the bottom of the screen. It has also a awareness of keyboard elements on those cases when keyboard is necessary to proceed with an action.
Resolves #
How this PR fixes it
How to test it
Screenshots
Checklist