eddieowens / react-native-boundary

Native implementation of geofencing/region monitoring

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error with Boundary.add

thomaslc66 opened this issue · comments

First install, react-native link is ok as i've check the manual config and everything seems ok.

Copy paste the example in the readme and got this error:
image

Maybe someone already encountred this?

I'm using an emulator and probaly will test it on a real phone to see if it's something related.

There doesn't seem to be anything in this stack that is related to the lib. I'm not entirely sure what's wrong here. Does your app have any other dependencies? Is it just a clean app with only react-native-boundary installed?

Yes my project is a react-native init app and then a copy paste of the permissions and of the componentWillmount and unmount method from your readme.md

Here you can find the complete repo : https://github.com/thomaslc66/Geofences

@eddieowens I don't know why but the Boundary.add() method is always going to catch an error.

@thomaslc66 I'm not seeing the "error :(" message in this stack. Is this the full stack? If there was an error in the add method I would expect to see something referencing that component.

@eddieowens did you clone my repo and launched it ? Because you would have seen it.

First install, react-native link is ok as i've check the manual config and everything seems ok.

Copy paste the example in the readme and got this error:
image

Maybe someone already encountred this?

I'm using an emulator and probaly will test it on a real phone to see if it's something related.

same issue,any solution yet ?

Have the same issue on the first run for iOS. The window with location permissions appears and the red screen as well on calling Boundary.add. When the permission has been already granted the same code does not raise the issue.
I use 'standard' check for the permissions before adding an area:

    if (Platform.OS === "android") {
        PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION)
            .then(granted => {
                if (granted === PermissionsAndroid.RESULTS.GRANTED) {
                    handleLocationAllowed();
                }
            });
    }
    else{
        handleLocationAllowed();
    }

I think solution should be somewhere here and the code should wait until permission is granted for iOS but I have no idea how to do it now. Usually it is recommended to do like in my code.
Want to try react-native-permissions library to check if location is allowed for iOS as well beforehand.

UPDATE:
I managed to fix the issue due to the library. So the code now is the following:

   Permissions.check("location").then(response => {
        switch(response){
            case "undetermined":
                //wait for the response
                Permissions.request("location", "always").then(response => {
                    if(response == "authorized" || response == "restricted"){
                        handleLocationAllowed();
                    }
                });
            break;

            case "authorized":
            case "restricted":
                handleLocationAllowed();
            break;
        }
    });   

This is called BEFORE adding anything into Boundary. Adding is called in 'handleLocationAllowed() method.