Skip to content

Latest commit

 

History

History
156 lines (133 loc) · 4.32 KB

INSTALL-EXPO.md

File metadata and controls

156 lines (133 loc) · 4.32 KB

Expo Setup

npx expo install react-native-background-geolocation
npx expo install react-native-background-fetch
npx expo install expo-gradle-ext-vars

📂 app.json

  • Add the following three plugins:
{
  "expo": {
    "name": "your-app-name",
    "plugins": [
+     [
+       "react-native-background-geolocation", {
+         "license": "YOUR_LICENSE_KEY_HERE"
+       }
+     ],
+     [
+       "expo-gradle-ext-vars", {
+         "googlePlayServicesLocationVersion": "21.1.0",
+         "appCompatVersion": "1.4.2"
+       }
+     ],
+     "react-native-background-fetch"
    ]
  }
}

Huawei Mobile Services (HMS) Support

If you've purchased an HMS Background Geolocation License for installing the plugin on Huawei devices without Google Play Services installed, add your HMS Background Geolocation license key:

{
  "expo": {
    "name": "your-app-name",
    "plugins": [
      [
        "react-native-background-geolocation", {
          "license": "YOUR_LICENSE_KEY_HERE",
+         "hmsLicense": "YOUR_HMS_LICENSE_HERE"
        }
      ]
    ]
  }
}

⚠️ Huawei HMS support requires react-native-background-geolocation >= 3.11.0.

Info.plist: Usage Descriptions

  • Add the following Usage Descriptions to the ios.infoPlist section:
  • These strings are used by the OS when requesting permission from the user. It's up to you to re-write these strings as-desired.
{
  "expo": {
    "name": "your-app-name",
    .
    .
    .
    "ios": {
+     "infoPlist": {
+       "NSLocationAlwaysAndWhenInUseUsageDescription": "[CHANGEME] This app requires location in the background",
+       "NSLocationWhenInUseUsageDescription": "[CHANGEME] This app requires location while in use",
+       "NSMotionUsageDescription": "[CHANGEME] This app uses motion-detection to determine the motion-activity of the device (walking, vehicle, bicycle, etc)"
+     }
    }
  }
}
  • If you configure the plugin with locationAuthorizationRequest: 'WhenInUse', you can omit NSLocationAlwaysAndWhenInUseUsageDescription
  • If you configure the plugin with disableMotionActivityUpdates: true, you can omit NSMotionUsageDescription

Info.plist: UIBackgroundModes:

  • Add the following UIBackgroundModes to the ios.infoPlist section:
{
  "expo": {
    "name": "your-app-name",
    .
    .
    .
    "ios": {
      "infoPlist": {
        "NSLocationAlwaysAndWhenInUseUsageDescription": "[CHANGEME] This app requires location in the background",
        "NSLocationWhenInUseUsageDescription": "[CHANGEME] This app requires location while in use",
        "NSMotionUsageDescription": "[CHANGEME] This app uses motion-detection to determine the motion-activity of the device (walking, vehicle, bicycle, etc)",
+       "UIBackgroundModes": [
+         "location",
+         "fetch",
+         "processing"
+       ],
+       "BGTaskSchedulerPermittedIdentifiers": [
+         "com.transistorsoft.fetch",
+         "com.transistorsoft.customtask"
+       ]
      }
    }
  }
}
  • While field-testing the plugin configured with debug: true (to enable debug found FX), you can optionally add the UIBackgroundMode audio so you can hear debug sounds while your app is in the background:
{
  "expo": {
    "name": "your-app-name",
    .
    .
    .
    "ios": {
      "infoPlist": {
        "NSLocationAlwaysAndWhenInUseUsageDescription": "[CHANGEME] This app requires location in the background",
        "NSLocationWhenInUseUsageDescription": "[CHANGEME] This app requires location while in use",
        "NSMotionUsageDescription": "[CHANGEME] This app uses motion-detection to determine the motion-activity of the device (walking, vehicle, bicycle, etc)",
        "UIBackgroundModes": [
          "location",
          "fetch",
          "processing",
+         "audio"
        ]
      }
    }
  }
}

Re-build

You must rebuild your Android app for the added plugins to be evaluated.

  • If you're developing locally:
npx expo prebuild
  • If you're using Expo EAS, you must first run eas build.
  • Adjust --profile as desired.
  • You must build ALL platforms, both iOS and Android:
 eas build --profile development