Hi @antoniomartos
Instead of using PermissionsKepler from “@amzn/react-native-kepler” , can you try the following?
import { usePermissionsKepler, PERMISSIONS } from '@amzn/react-native-kepler';
I tried this and did not face the Geolocation Permissions issue.
Sharing my App.tsx snippet here.
/*
* Copyright (c) 2022 Amazon.com, Inc. or its affiliates. All rights reserved.
*
* PROPRIETARY/CONFIDENTIAL. USE IS SUBJECT TO LICENSE TERMS.
*/
import React, {useState, useEffect} from 'react';
import {StyleSheet, Text, ImageBackground, View, Image} from 'react-native';
import {Link} from './components/Link';
import {usePermissionsKepler, PERMISSIONS} from '@amzn/react-native-kepler';
const images = {
kepler: require('./assets/kepler.png'),
learn: require('./assets/learn.png'),
support: require('./assets/support.png'),
build: require('./assets/build.png'),
};
export const App = () => {
const [image, setImage] = useState(images.kepler);
const [permissionStatus, setPermissionStatus] = useState('checking');
const [check, request] = usePermissionsKepler();
const requestLocationPermission = async () => {
try {
const hasPermission = await check(PERMISSIONS.ACCESS_FINE_LOCATION);
if (hasPermission) {
console.log('Location permission already granted');
setPermissionStatus('granted');
return true;
}
const requestResult = await request(PERMISSIONS.ACCESS_FINE_LOCATION);
console.log('Permission request result:', requestResult);
setPermissionStatus(requestResult === 'granted' ? 'granted' : 'denied');
return requestResult === 'granted';
} catch (error) {
console.error('Permission error:', error);
setPermissionStatus('error');
return false;
}
};
useEffect(() => {
requestLocationPermission();
}, []);
const styles = getStyles();
return (
<ImageBackground
source={require('./assets/background.png')}
style={styles.background}>
<View style={styles.container}>
<View style={styles.links}>
<View style={styles.headerContainer}>
<Text style={styles.headerText}>Hello World!</Text>
<Text style={styles.subHeaderText}>
Select one of the options below to start your Kepler journey 🚀
</Text>
<Text style={styles.permissionText}>
Location Permission: {permissionStatus}
</Text>
</View>
<Link
linkText={'Learn'}
onPress={() => {
setImage(images.learn);
}}
testID="sampleLink"
/>
<Link
linkText={'Build'}
onPress={() => {
setImage(images.build);
}}
/>
<Link
linkText={'Support'}
onPress={() => {
setImage(images.support);
}}
/>
</View>
<View style={styles.image}>
<Image source={image} />
</View>
</View>
<View style={styles.textContainer}>
<Text style={styles.text}>
💡 Edit App.tsx to change this screen and then come back to see your
edits
</Text>
</View>
</ImageBackground>
);
};
const getStyles = () =>
StyleSheet.create({
background: {
color: 'white',
flex: 1,
flexDirection: 'column',
},
container: {
flex: 6,
flexDirection: 'row',
alignItems: 'center',
},
headerContainer: {
marginLeft: 200,
},
headerText: {
color: 'white',
fontSize: 80,
marginBottom: 10,
},
subHeaderText: {
color: 'white',
fontSize: 40,
},
links: {
flex: 1,
flexDirection: 'column',
justifyContent: 'space-around',
height: 600,
},
image: {
flex: 1,
paddingLeft: 150,
},
textContainer: {
justifyContent: 'center',
flex: 1,
marginLeft: 190,
},
text: {
color: 'white',
fontSize: 40,
},
permissionText: {
color: 'white',
fontSize: 30,
marginTop: 20,
},
});
Please try and let me know if this helps.
Warm regards,
Ivy