Skip to content

Cannot fetch user location #20

@indranil316

Description

@indranil316

Please help.

I am trying to use wikitude in react native but the app cannot fetch location, I dont know why.

I gave location permission still its not working.

I am posting the code.

App.js :--
`import React, {Component} from 'react';
import {Text,View,StyleSheet,SafeAreaView} from 'react-native';
import { PermissionsAndroid } from 'react-native';
import Wikitude from './screens/Wikitude';

export default class App extends Component{
constructor(){
super();
this.state={
locPerm:false
}
}
async componentDidMount(){
await this.requestLocationPermission();
}
requestLocationPermission=async ()=>{
try{
const granted = await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
{
'title': 'Example App',
'message': 'Example App access to your location '
}
)
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
console.log("You can use the location")
alert("You can use the location");
this.setState({locPerm:true})
} else {
console.log("location permission denied")
alert("Location permission denied");
}
} catch (err) {
console.warn(err)
}
}
render(){
const {locPerm}=this.state;
console.log(locPerm)
if(locPerm===true){
return
}
return(

Please allow location permission

)
}
}

const styles=StyleSheet.create({
fullScreen:{
flex:1
}
})`

Wikitude.js :--
`import React from 'react';
import {WikitudeView} from 'react-native-wikitude-sdk';
import {Platform,StyleSheet,SafeAreaView} from 'react-native';
import Share from "react-native-share";

export default class Wikitude extends React.Component {
constructor(){
super();
this.state={
wikitudeLicense:'My lisence key',
url:'/assets/index'
}
this.wikiref=React.createRef();
}
takeScreenshot = () => {
if (this.wikitudeView.current) {
this.wikitudeView.current.captureScreen(true);
}
};
getUrl=()=>{
let url=this.state.url;
if(Platform.OS==='android'){
url = url.replace('/assets/', '');
}
return url;
}
onFinishLoading = event => {
console.log("loading finished"+JSON.stringify(event.message))
};
onFailLoading = event => {
console.log("fail"+JSON.stringify(event))
};
onJsonReceived = event => {
console.log("JSON recieved : "+JSON.stringify(event.action))
console.log(this.wikiref.current.state.isRunning=true)
};
onScreenCaptured = event => {
if(!event.image) return;

Share.open({
message: 'Share this awesome AR',
title: 'Share!',
url: event.image,
})
.then(res => {
console.log(res);
})
.catch(err => {
err && console.log(err);
});

};
stream=()=>{
console.log('ok')
}
render(){
const {wikitudeLicense}=this.state;
return (

);
}
}

const styles = StyleSheet.create({
AR: {
position: 'absolute',
top: 0,
bottom: 0,
left: 0,
right: 0,
backgroundColor: 'transparent',
alignItems: 'center',
justifyContent: 'center',
},
container: {
flex: 1,
backgroundColor: 'transparent',
},
});`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions