Error when using startGeofencingAsync() from Expo Locations

Please provide the following:

  1. SDK Version: 37
  2. Platforms(Android/iOS/web/all): All (specifically iOS Simulator)

Hello Everyone! :slight_smile:

I’ve been following the documentation trying to implement the startGeofencingAsync function. However, I’m getting the following error.

Error: Invalid parameter not satisfying: !stayUp || CLClientIsBackgroundable(internal->fClient) || _CFMZEnabled()

I’ve followed the exact directions and the code that the Expo documentation provides. Initially, I’ve started by importing the correct libraries.

Here, I’m defining it in the global scope of my Javascript bundle.

const LOCATION_TASK_NAME = "background-location-task";
TaskManager.defineTask(LOCATION_TASK_NAME, ({ data, error }) => {
  if (error) {
    // Error occurred - check `error.message` for more details.
    return;
  }
  if (data) {
    const { locations } = data;
    // do something with the locations captured in the background
    console.log("Location data from Task Manager = " + locations);
  }
});

Here, I have my startGeofencingAsync method in the componentDidMount method.

    Location.startGeofencingAsync("LOCATION_TASK_NAME", [
      {
        identifier: "1",
        latitude: 40.743293,
        longitude: -73.9904096,
        radius: 50,
        notifyOnEnter: true,
        notifyOnExit: true,
      },
    ])
      .then((response) => {
        if (response) {
          console.log("Response from startGeoFencingAsync() = " + response);
        }
      })
      .catch((error) => {
        if (error) {
          console.log("Error from startGeoFencingAsync() = " + error);
        }
      });

Unfortunately, I’ve been trying to debug this issue for the last several days but to no avail. Does anyone have a clue as to what the issue may be?

Thanks!!

Anyone experiencing the same issue, solved this issue, or can help in any way?

Thanks!

Hello,

maybe try :

Location.startGeofencingAsync(LOCATION_TASK_NAME, [

without " " ?

Hi! Thanks for your response.

I’ve tried it both ways, and unfortunately, I still get the same error.

Hi !

Did you add "UIBackgroundModes : ‘location’ " and “NSLocationAlwaysUsageDescription” to Info.plist ? This seems to be important for iOS.

Hoping to help you :slight_smile:

Thank so much for following up on this.

Yes, I’ve added that to my info.plist. Here’s the code below:

      "infoPlist": {
        "userInterfaceStyle": "light",
        "UIBackgroundModes": ["location", "fetch"],
        "allowsBackgroundLocationUpdates": true,
        "NSLocationAlwaysUsageDescription": "App requires for enabling geofencing.",
        "NSLocationWhenInUseUsageDescription": "User's location is used to show where they are in relation to an activity's location that they are interested in attending.",
        "NSLocationAlwaysAndWhenInUseUsageDescription": "App requires for enabling geofencing"
      }

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.