transistorsoft / cordova-background-geolocation-lt

The most sophisticated background location-tracking & geofencing module with battery-conscious motion-detection intelligence for iOS and Android.
http://www.transistorsoft.com/shop/products/cordova-background-geolocation
Other
661 stars 276 forks source link

Callbacks to window.BackgroundGeolocation.configure or ready do not get called. #646

Closed t2wu closed 6 years ago

t2wu commented 6 years ago

Your Environment

  <variable name="LICENSE" value="YOUR_LICENSE_KEY" />
        <variable name="GOOGLE_API_VERSION" value="11.8.0" />
        <variable name="APPCOMPAT_VERSION" value="27.0.0" />
        <variable name="BACKGROUND_MODE_LOCATION" value="&lt;string&gt;location&lt;/string&gt;" />
        <variable name="LOCATION_ALWAYS_AND_WHEN_IN_USE_USAGE_DESCRIPTION" value="Always use is required for constant background location-tra
        <variable name="LOCATION_ALWAYS_USAGE_DESCRIPTION" value="Background location-tracking is required" />
        <variable name="LOCATION_WHEN_IN_USE_USAGE_DESCRIPTION" value="Background location-tracking is required" />
        <variable name="MOTION_USAGE_DESCRIPTION" value="Using the accelerometer increases battery-efficiency by intelligently toggling locat

Expected Behavior

Either error callback or success callback should be called.

Actual Behavior

Neither error callback or success callback gets called.

Steps to Reproduce

  1. Code like this. (This now is run when app starts up and the user has logged in.)
    window.BackgroundGeolocation.configure({
      desiredAccuracy: 1000, // <-- Config params // 0, 10, 100, 1000, where 1000 is the lowest accuracy
      distanceFilter: 50,
      timeout: 40000, // 40 seconds for every location fetch
      activityRecognitionInterval: 10000, // android
      // locationUpdateInterval: 1000,// With distanceFilter: 0, Sets the desired interval for location updates, in milliseconds.
      timeout: 3000,
      geofenceInitialTriggerEntry: true,
      fastestLocationUpdateInterval: 10000,
      forceReloadOnGeofence: true,
    }, (state) => { // <-- Current state provided to #configure callback
      console.log('BackgroundGeolocation is configured and ready to use. State:' + JSON.stringify(state));
      /*
      if (!state.enabled) {
      } else {
      }
      */
    }, (err) => {
      console.log(`Background Geolocation failed to configure: ${err.message}`);
    });
    }
  2. That's it.

Context

Configure parameters for Geofence.

Debug logs

Not sure what to look for here.

christocracy commented 6 years ago
$ cordova plugins
t2wu commented 6 years ago

com.colibrisoftware.plugins.backgroundjs 3.3 "BackgroundJS" com.pylonproducts.wifiwizard 0.2.11 "WifiWizard" com.unarin.cordova.beacon 3.5.2 "Proximity Beacon Plugin" com.vallieres.plugin.getrouteripaddress 1.0.0 "GetRouterIPAddress" cordova-background-geolocation-lt 2.11.0-beta.2 "BackgroundGeolocation" cordova-ios-plugin-no-export-compliance 0.0.5 "iOS No Export Compliance" cordova-open-native-settings 1.4.1 "Native settings" cordova-plugin-add-swift-support 1.7.1 "AddSwiftSupport" cordova-plugin-android-permissions 1.0.0 "Permissions" cordova-plugin-android-wifi-manager 1.0.0 "Android WifiManager" cordova-plugin-app-version 0.1.9 "AppVersion" cordova-plugin-backbutton 0.3.0 "Backbutton" cordova-plugin-background-fetch 5.3.0 "CDVBackgroundFetch" cordova-plugin-badge 0.8.6 "Badge" cordova-plugin-bluenet-dfu 0.0.2 "Bluenet DFU" cordova-plugin-bluetooth-status 1.0.4 "Bluetooth status" cordova-plugin-bluetoothle 4.4.3 "Bluetooth LE" cordova-plugin-buildinfo 2.0.1 "BuildInfo" cordova-plugin-camera 4.0.1 "Camera" cordova-plugin-cocoalumberjack 0.0.4 "CocoaLumberjack" cordova-plugin-compat 1.2.0 "Compat" cordova-plugin-console 1.1.0 "Console" cordova-plugin-device 2.0.1 "Device" cordova-plugin-dialogs 2.0.1 "Notification" cordova-plugin-file 6.0.1 "File" cordova-plugin-firebase 0.1.25 "Google Firebase Plugin" cordova-plugin-geolocation 4.0.1 "Geolocation" cordova-plugin-inappbrowser 2.0.1 "InAppBrowser" cordova-plugin-insomnia 4.3.0 "Insomnia (prevent screen sleep)" cordova-plugin-ios-disableshaketoedit 1.0.0 "iOS Disable Shake to Edit" cordova-plugin-keyboard 1.2.0 "Keyboard" cordova-plugin-local-notification 0.9.0-beta.1 "LocalNotification" cordova-plugin-localization-strings 1.1.1 "Localization" cordova-plugin-network-information 2.0.1 "Network Information" cordova-plugin-smartconfig 1.0.1 "Cordova Smart Config" cordova-plugin-splashscreen 5.0.1 "Splashscreen" cordova-plugin-statusbar 2.4.1 "StatusBar" cordova-plugin-whitelist 1.3.3 "Whitelist" phonegap-plugin-barcodescanner 7.0.2 "BarcodeScanner"

christocracy commented 6 years ago

Show me logs of your app booting:

$ adb logcat
t2wu commented 6 years ago

logOnAppLaunch.txt.zip

erbg commented 6 years ago

Same problem here. Do you have an update?

christocracy commented 6 years ago

@t2wu and @erbg show me your platforms/android/project.properties. You have multiple plugins requiring different versions of google play-services dependencies.

erbg commented 6 years ago

target=android-26 android.library.reference.1=CordovaLib cordova.gradle.include.1=cordova-plugin-background-fetch/driverapp-build.gradle cordova.system.library.1=com.android.support:support-v4:24.1.1+ cordova.system.library.2=com.soundcloud.android:android-crop:1.0.0@aar cordova.system.library.3=com.android.support:support-v4:25.+ cordova.system.library.4=com.android.support:appcompat-v7:25.+ cordova.system.library.5=com.microsoft.azure:azure-mobile-android:3.3.0@aar cordova.gradle.include.2=phonegap-plugin-barcodescanner/driverapp-barcodescanner.gradle cordova.system.library.6=com.android.support:support-v4:27.+ cordova.gradle.include.3=cordova-background-geolocation-lt/driverapp-build.gradle cordova.system.library.8=com.google.android.gms:play-services-gcm:15+ cordova.system.library.9=me.leolin:ShortcutBadger:1.1.14@aar cordova.system.library.10=com.google.android.gms:play-services-location:11.8.0 cordova.system.library.11=com.android.support:appcompat-v7:27.0.0 cordova.system.library.7=com.android.support:support-v13:26.+ cordova.system.library.12=me.leolin:ShortcutBadger:1.1.17@aar cordova.system.library.13=com.google.firebase:firebase-messaging:11.6.2 cordova.gradle.include.4=phonegap-plugin-push/driverapp-push.gradle

erbg commented 6 years ago

May it be related to the use of the phonegap-plugin-push@1..?

t2wu commented 6 years ago

I pasted it in another thread (the one about app crash). So I guess it's the same solution to both problems, I need to use the same google play services. How do I configure them though?

christocracy commented 6 years ago

background-geolocation allows you to configure the desired play-services version via its GOOGLE_API_VERSION

phonegap-plugin-push supports configuring play-services version via its similar FCM_VERSION.

Each plugin importing google-play-services (or Firebase) should have a similar "variable" (you'll have to consult with each plugin to determine this).

Firebase version must be identical to Play Services version.

You can modify platforms/android/project.properties directly but this file is volatile -- it will be destroyed and re-generated every time you remove / re-add the android platform.

Also, Google Support libraries must all be aligned to the same version. Background Geolocation also provides an APP_COMPAT_VERSION config variable. phonegap-plugin-push provides ANDROID_SUPPORT_V13_VERSION.

When you have support libs all pointing to different versions, you have problems:

cordova.system.library.1=com.android.support:support-v4:24.1.1+
cordova.system.library.3=com.android.support:support-v4:25.+
cordova.system.library.4=com.android.support:appcompat-v7:25.+
cordova.system.library.6=com.android.support:support-v4:27.+
cordova.system.library.11=com.android.support:appcompat-v7:27.0.0
cordova.system.library.7=com.android.support:support-v13:26.+

The root support lib version should be greater then or equal to your target version (in your case target=android-26.

All these support lib versions must be aligned to the same version (eg: 27.0.0)

t2wu commented 6 years ago

OK I used an old version of cordova-plugin-firebase (hash 79dbf49) and and consulted this thread and managed to get it to compile.

And boy am I glad to see the license validation warning! Problem solved!

erbg commented 6 years ago

Ok, we updated our Push Plugin to version 2.0 and setted the Google_api_version accordingly. Problem is solved. Thanks