An ATproto social media client -- with an independent Appview.
6
fork

Configure Feed

Select the types of activity you want to include in your feed.

Check `canAskAgain` for notification permissions (#4460)

authored by

Hailey and committed by
GitHub
5dd195bc 90ec22a6

+15 -3
+8 -2
src/lib/notifications/notifications.ts
··· 72 72 73 73 export function useRequestNotificationsPermission() { 74 74 const gate = useGate() 75 + const {currentAccount} = useSession() 75 76 76 - return async (context: 'StartOnboarding' | 'AfterOnboarding' | 'Login') => { 77 + return async ( 78 + context: 'StartOnboarding' | 'AfterOnboarding' | 'Login' | 'Home', 79 + ) => { 77 80 const permissions = await Notifications.getPermissionsAsync() 78 81 79 82 if ( 80 83 !isNative || 81 84 permissions?.status === 'granted' || 82 - permissions?.status === 'denied' 85 + (permissions?.status === 'denied' && !permissions.canAskAgain) 83 86 ) { 84 87 return 85 88 } ··· 93 96 context === 'AfterOnboarding' && 94 97 !gate('request_notifications_permission_after_onboarding_v2') 95 98 ) { 99 + return 100 + } 101 + if (context === 'Home' && !currentAccount) { 96 102 return 97 103 } 98 104
+1 -1
src/lib/statsig/events.ts
··· 17 17 } 18 18 'notifications:openApp': {} 19 19 'notifications:request': { 20 - context: 'StartOnboarding' | 'AfterOnboarding' | 'Login' 20 + context: 'StartOnboarding' | 'AfterOnboarding' | 'Login' | 'Home' 21 21 status: 'granted' | 'denied' | 'undetermined' 22 22 } 23 23 'state:background:sampled': {
+6
src/view/screens/Home.tsx
··· 20 20 } from '#/state/shell' 21 21 import {useSelectedFeed, useSetSelectedFeed} from '#/state/shell/selected-feed' 22 22 import {useOTAUpdates} from 'lib/hooks/useOTAUpdates' 23 + import {useRequestNotificationsPermission} from 'lib/notifications/notifications' 23 24 import {HomeTabNavigatorParams, NativeStackScreenProps} from 'lib/routes/types' 24 25 import {FeedPage} from 'view/com/feeds/FeedPage' 25 26 import {Pager, PagerRef, RenderTabBarFnProps} from 'view/com/pager/Pager' ··· 67 68 const maybeFoundIndex = allFeeds.indexOf(rawSelectedFeed) 68 69 const selectedIndex = Math.max(0, maybeFoundIndex) 69 70 const selectedFeed = allFeeds[selectedIndex] 71 + const requestNotificationsPermission = useRequestNotificationsPermission() 70 72 71 73 useSetTitle(pinnedFeedInfos[selectedIndex]?.displayName) 72 74 useOTAUpdates() 75 + 76 + React.useEffect(() => { 77 + requestNotificationsPermission('Home') 78 + }, [requestNotificationsPermission]) 73 79 74 80 const pagerRef = React.useRef<PagerRef>(null) 75 81 const lastPagerReportedIndexRef = React.useRef(selectedIndex)