transistorsoft / react-native-background-geolocation

Sophisticated, battery-conscious background-geolocation with motion-detection
http://shop.transistorsoft.com/pages/react-native-background-geolocation
MIT License
2.54k stars 424 forks source link

Where to Add License key on iOS whereas Android part is mentioned on the ReadMe #1970

Closed mohan2002 closed 1 month ago

mohan2002 commented 1 month ago

I wasn't able to find a place where to add LICENSE KEY on iOS. Planning to buy the Licensed version

Can I know the exact places to be added for LICENSE KEY to be added for iOS and Android.

Quick question:

[Context: React Native]

App getting crashed when I ran the debug version of implementation on iOS - debug mode - App ran from Xcode.

Is this expected ? Will this be resolved when the License key is added. It is working fine on the iOS simulator, Android simulator even app ran on Android real device by connecting to same wifi.

@christocracy Would be happier to get a solution for above issue and from then this issue can be closed.

christocracy commented 1 month ago

Only Android consumes keys. The Setup Instructions linked in the readme tell you everything you need to do.

App getting crashed when I ran the debug version of implementation on iOS

if you have a crash, show the stacktrace from XCode

mohan2002 commented 1 month ago

I'm getting

Sending providerchange with no listeners registered. From the debugger

Here is my code

BackgroundGeolocation.ready({
  desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
  distanceFilter: 10,
  stopTimeout: 1000,
  debug: false,
  logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE,
  stopOnTerminate: false,
  startOnBoot: true,
  params: {
    auth_token: 'maybe_your_server_authenticates_via_token_YES?',
  },
}).then((state) => {
  console.log('- BackgroundGeolocation is configured and ready: ', state.enabled)
})

BackgroundGeolocation.start()

await BackgroundGeolocation.getCurrentPosition({
  persist: true,
  samples: 2,
  timeout: 1000,
  maximumAge: 10000,
  extras: {
    getCurrentPosition: true,
  },
})
  .then((location: Location) => {
    console.log('πŸš€ ~ .then ~ location:', location)
    const { longitude, latitude, altitude, accuracy } = location.coords
    const locationDetails = {
      longitude,
      latitude,
      altitude,
      accuracy,
      timestamp: new Date(),
    }
    if (setFieldValue && fieldName) {
      setFieldValue(fieldName, JSON.stringify(locationDetails))
      setUserLoading(false)
    }
  })
  .catch((error: LocationError) => {
    console.warn('[getCurrentPosition] error: ', error)
  })

BackgroundGeolocation.stop()
christocracy commented 1 month ago

Sending providerchange with no listeners registered.

You don't need to worry about this, it's harmess. It's expected when you haven't registered a listener for that event.

You can optionally listen to that event if you wish:

BackgroundGeolcoation.onProviderChange((event) => {
  console.log('[onProviderChange]', event);
});
christocracy commented 1 month ago

Also, you must await BackgroundGeolocation.ready(config) BEFORE calling .start() or .getCurrentPosition.

christocracy commented 1 month ago
// NO!!
BackgroundGeolocation.ready(config)
BackgroundGeolocation.start();

// YES
await BackgroundGeolocation.ready(config)  // <-- MUST await .ready(config)
BackgroundGeolocation.start();
mohan2002 commented 1 month ago

Thanks @christocracy. Let me check the above.

If the react native version is greater than 0.60

https://github.com/transistorsoft/react-native-background-geolocation/blob/master/help/INSTALL-IOS-AUTO.md

The whole process of auto linking above is not needed right?

christocracy commented 1 month ago

You MUST Follow the Auto-Linking Instructions.

mohan2002 commented 1 month ago

Oh thanks @christocracy

mohan2002 commented 1 month ago

This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSMotionUsageDescription key with a string value explaining to the user how the app uses this data.

I'm getting this,

But I've added the privacy in the info list

image

Anything on this @christocracy

christocracy commented 1 month ago

Show me a screenshot of your entire Info.plist

mohan2002 commented 1 month ago

@christocracy

image

Getting error,

╔═══════════════════════════════════════════════════════════ β•‘ -[TSHttpService finish:error:] Success: 1 β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β• This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSMotionUsageDescription key with a string value explaining to the user how the app uses this data. ℹ️+[LocationAuthorization run:onCancel:] status: 0 ℹ️-[TSConfig persist] πŸ”΅+[LocationAuthorization run:onCancel:] Request: requestAlwaysAuthorization

mohan2002 commented 1 month ago

Anything on this @christocracy

christocracy commented 1 month ago

Post your raw Info.plist file contents.

mohan2002 commented 1 month ago
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>BGTaskSchedulerPermittedIdentifiers</key>
    <array>
        <string>com.transistorsoft.fetch</string>
        <string>com.transistorsoft.customtask</string>
        <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    </array>
    <key>CFBundleDevelopmentRegion</key>
    <string>en</string>
    <key>CFBundleDisplayName</key>
    <string>PRODUCTNAME AI</string>
    <key>CFBundleExecutable</key>
    <string>$(EXECUTABLE_NAME)</string>
    <key>CFBundleIdentifier</key>
    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>$(PRODUCT_NAME)</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0.22</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>None</string>
            <key>CFBundleURLName</key>
            <string>auth0</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
            </array>
        </dict>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>PRODUCTNAME</string>
            </array>
        </dict>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>ai.PRODUCTNAME</string>
            </array>
        </dict>
    </array>
    <key>CFBundleVersion</key>
    <string>1</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSExceptionDomains</key>
        <dict>
            <key>https://apim-u4xiw5amstzbe.azure-api.net</key>
            <dict>
                <key>NSExceptionAllowsInsecureHTTPLoads</key>
                <true/>
                <key>NSIncludesSubdomains</key>
                <true/>
            </dict>
            <key>localhost</key>
            <dict>
                <key>NSExceptionAllowsInsecureHTTPLoads</key>
                <true/>
            </dict>
        </dict>
    </dict>
    <key>NSAppleMusicUsageDescription</key>
    <string>To upload work order related artefacts from your gallery, PRODUCTNAME AI requires access to your files, photos and videos.</string>
    <key>NSCameraUsageDescription</key>
    <string>To take a picture or video related to the work order to upload onto PRODUCTNAME AI, please authorize PRODUCTNAME AI to access your camera.</string>
    <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
    <string>Location access is required for validating your day&apos;s work and submissions as requested by your organization.</string>
    <key>NSLocationAlwaysUsageDescription</key>
    <string>Location access is required for validating your day&apos;s work and submissions as requested by your organization.</string>
    <key>NSLocationTemporaryUsageDescriptionDictionary</key>
    <dict>
        <key>forms</key>
        <string>Location access is required for validating your day&apos;s work and submissions as requested by your organization.</string>
    </dict>
    <key>NSLocationWhenInUseUsageDescription</key>
    <string>Location access is required for validating your day&apos;s work and submissions as requested by your organization.</string>
    <key>NSMicrophoneUsageDescription</key>
    <string>To upload work order related artefacts from your gallery, PRODUCTNAME AI requires access to your microphone </string>
    <key>NSPhotoLibraryAddUsageDescription</key>
    <string>To upload work order related artefacts from your gallery, PRODUCTNAME AI requires access to your files, photos and videos.</string>
    <key>NSPhotoLibraryUsageDescription</key>
    <string>To upload work order related artefacts from your gallery, PRODUCTNAME AI requires access to your files, photos and videos.</string>
    <key>UIAppFonts</key>
    <array>
        <string>Lato-Bold.ttf</string>
        <string>Lato-Light.ttf</string>
        <string>Lato-Medium.ttf</string>
        <string>Lato-Regular.ttf</string>
        <string>timer.ttf</string>
    </array>
    <key>UIBackgroundModes</key>
    <array>
        <string>audio</string>
        <string>fetch</string>
        <string>location</string>
        <string>processing</string>
        <string>remote-notification</string>
    </array>
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>UIRequiredDeviceCapabilities</key>
    <array>
        <string>armv7</string>
    </array>
    <key>UIRequiresFullScreen</key>
    <true/>
    <key>UIStatusBarStyle</key>
    <string>UIStatusBarStyleDarkContent</string>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
        <string>UIInterfaceOrientationPortrait</string>
    </array>
    <key>UIViewControllerBasedStatusBarAppearance</key>
    <true/>
    <key>NSMotionUsageDescription</key>
    <string>[CHANGEME] Motion Usage Description</string>
</dict>
</plist>
christocracy commented 1 month ago

Everything looks perfect:

<key>NSMotionUsageDescription</key>
<string>[CHANGEME] Motion Usage Description</string>

I have no idea what you’re doing wrong. Are you sure this Info.plist comes from the App you’re actually running?

mohan2002 commented 1 month ago

Yes. So the key and value are correct right?

christocracy commented 1 month ago

Yes. Like I said: β€œEverything looks perfect”

christocracy commented 1 month ago

I suggest you terminate / restart XCode. Run your app directly from XCode.

mohan2002 commented 1 month ago

Thanks @christocracy. I resolved the issue. Working fine.