@@ -37,28 +37,36 @@ export function SimpleTab() {
3737
3838 const [ activities , refreshActivities ] = useActivities ( ) ;
3939
40- const onPressRequestCallback = useCallback ( async ( ) => {
41- if ( authorizationStatus === AuthorizationStatus . notDetermined ) {
42- await requestAuthorization ( ) ;
43- } else if ( authorizationStatus === AuthorizationStatus . denied ) {
44- Alert . alert (
45- "You didn't grant access" ,
46- "Please go to settings and enable it" ,
47- [
48- {
49- text : "Open settings" ,
50- onPress : ( ) => Linking . openSettings ( ) ,
51- } ,
52- {
53- text : "Cancel" ,
54- style : "cancel" ,
55- } ,
56- ] ,
57- ) ;
58- } else {
59- await revokeAuthorization ( ) ;
60- }
61- } , [ authorizationStatus ] ) ;
40+ const onPressRequestCallback = useCallback (
41+ async ( forIndividualOrChild : "individual" | "child" = "individual" ) => {
42+ if ( authorizationStatus === AuthorizationStatus . notDetermined ) {
43+ try {
44+ await requestAuthorization ( forIndividualOrChild ) ;
45+ } catch ( e ) {
46+ Alert . alert ( "Error requesting authorization" , ( e as Error ) . message ) ;
47+ console . log ( "Error requesting authorization" , e ) ;
48+ }
49+ } else if ( authorizationStatus === AuthorizationStatus . denied ) {
50+ Alert . alert (
51+ "You didn't grant access" ,
52+ "Please go to settings and enable it" ,
53+ [
54+ {
55+ text : "Open settings" ,
56+ onPress : ( ) => Linking . openSettings ( ) ,
57+ } ,
58+ {
59+ text : "Cancel" ,
60+ style : "cancel" ,
61+ } ,
62+ ] ,
63+ ) ;
64+ } else {
65+ await revokeAuthorization ( ) ;
66+ }
67+ } ,
68+ [ authorizationStatus ] ,
69+ ) ;
6270
6371 const [ showCreateActivityPopup , setShowCreateActivityPopup ] = useState ( false ) ;
6472
@@ -108,12 +116,21 @@ export function SimpleTab() {
108116 < Text style = { { flex : 1 } } >
109117 { authorizationStatusMap [ authorizationStatus ] }
110118 </ Text >
111-
112- < Button onPress = { onPressRequestCallback } mode = "contained" >
113- { authorizationStatus === AuthorizationStatus . approved
114- ? "Revoke authorization"
115- : "Request authorization" }
116- </ Button >
119+ < View style = { { gap : 10 } } >
120+ < Button onPress = { ( ) => onPressRequestCallback ( ) } mode = "contained" >
121+ { authorizationStatus === AuthorizationStatus . approved
122+ ? "Revoke authorization"
123+ : "Request authorization" }
124+ </ Button >
125+ < Button
126+ onPress = { ( ) => onPressRequestCallback ( "child" ) }
127+ mode = "contained"
128+ >
129+ { authorizationStatus === AuthorizationStatus . approved
130+ ? "Revoke child authorization"
131+ : "Request child authorization" }
132+ </ Button >
133+ </ View >
117134 </ View >
118135 < Title > Activities</ Title >
119136 { activities . map ( ( activity ) => (
0 commit comments