Move request for notifications permissions to HomeReadyScreen
(#3977)
* cleanup the current logic * add statsig logs * implement requests for permissions where needed * oops * let `addPushTokenListener` handle the token registration * place new log event type with the other `notifications` type * place registration next to handler * more organization * only call `gate()` if permission is not yet granted * be more specific to prevent gate pollution * nit * make `token` non-optional in `registerToken` * remove `prevDid`, move `registerPushToken` into `useEffect` * keep it outside actually * nit
This commit is contained in:
parent
63b38b413d
commit
d3406c89cf
7 changed files with 105 additions and 67 deletions
|
@ -5,11 +5,12 @@ import {useLingui} from '@lingui/react'
|
|||
import {useQuery} from '@tanstack/react-query'
|
||||
|
||||
import {useAnalytics} from '#/lib/analytics/analytics'
|
||||
import {logEvent} from '#/lib/statsig/statsig'
|
||||
import {logEvent, useGate} from '#/lib/statsig/statsig'
|
||||
import {capitalize} from '#/lib/strings/capitalize'
|
||||
import {logger} from '#/logger'
|
||||
import {useAgent} from '#/state/session'
|
||||
import {useOnboardingDispatch} from '#/state/shell'
|
||||
import {useRequestNotificationsPermission} from 'lib/notifications/notifications'
|
||||
import {
|
||||
DescriptionText,
|
||||
OnboardingControls,
|
||||
|
@ -33,6 +34,9 @@ export function StepInterests() {
|
|||
const t = useTheme()
|
||||
const {gtMobile} = useBreakpoints()
|
||||
const {track} = useAnalytics()
|
||||
const gate = useGate()
|
||||
const requestNotificationsPermission = useRequestNotificationsPermission()
|
||||
|
||||
const {state, dispatch, interestsDisplayNames} = React.useContext(Context)
|
||||
const [saving, setSaving] = React.useState(false)
|
||||
const [interests, setInterests] = React.useState<string[]>(
|
||||
|
@ -129,6 +133,12 @@ export function StepInterests() {
|
|||
track('OnboardingV2:StepInterests:Start')
|
||||
}, [track])
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!gate('reduced_onboarding_and_home_algo')) {
|
||||
requestNotificationsPermission('StartOnboarding')
|
||||
}
|
||||
}, [gate, requestNotificationsPermission])
|
||||
|
||||
const title = isError ? (
|
||||
<Trans>Oh no! Something went wrong.</Trans>
|
||||
) : (
|
||||
|
|
|
@ -10,11 +10,12 @@ import {msg, Trans} from '@lingui/macro'
|
|||
import {useLingui} from '@lingui/react'
|
||||
|
||||
import {useAnalytics} from '#/lib/analytics/analytics'
|
||||
import {logEvent} from '#/lib/statsig/statsig'
|
||||
import {logEvent, useGate} from '#/lib/statsig/statsig'
|
||||
import {usePhotoLibraryPermission} from 'lib/hooks/usePermissions'
|
||||
import {compressIfNeeded} from 'lib/media/manip'
|
||||
import {openCropper} from 'lib/media/picker'
|
||||
import {getDataUriSize} from 'lib/media/util'
|
||||
import {useRequestNotificationsPermission} from 'lib/notifications/notifications'
|
||||
import {isNative, isWeb} from 'platform/detection'
|
||||
import {
|
||||
DescriptionText,
|
||||
|
@ -69,6 +70,9 @@ export function StepProfile() {
|
|||
const {gtMobile} = useBreakpoints()
|
||||
const {track} = useAnalytics()
|
||||
const {requestPhotoAccessIfNeeded} = usePhotoLibraryPermission()
|
||||
const gate = useGate()
|
||||
const requestNotificationsPermission = useRequestNotificationsPermission()
|
||||
|
||||
const creatorControl = Dialog.useDialogControl()
|
||||
const [error, setError] = React.useState('')
|
||||
|
||||
|
@ -86,6 +90,14 @@ export function StepProfile() {
|
|||
track('OnboardingV2:StepProfile:Start')
|
||||
}, [track])
|
||||
|
||||
React.useEffect(() => {
|
||||
// We have an experiment running for redueced onboarding, where this screen shows up as the first in onboarding.
|
||||
// We only want to request permissions when that gate is actually active to prevent pollution
|
||||
if (gate('reduced_onboarding_and_home_algo')) {
|
||||
requestNotificationsPermission('StartOnboarding')
|
||||
}
|
||||
}, [gate, requestNotificationsPermission])
|
||||
|
||||
const openPicker = React.useCallback(
|
||||
async (opts?: ImagePickerOptions) => {
|
||||
const response = await launchImageLibraryAsync({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue