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
655 stars 277 forks source link

plugin does not call http url in ios #693

Closed aaronharper123 closed 5 years ago

aaronharper123 commented 5 years ago

I am new in your plugin , i set code from https://gist.github.com/christocracy/2abf5587cc12b83e15aa12958de7a7d2#file-backgroundgeolocation-ionic2-js but url not call with my params ... or not any success or error consoles are occurred. and also i want to track user even user terminate the app.

Your Environment

Expected Behavior

Actual Behavior

Steps to Reproduce

1. 2. 3. 4.

Context

Debug logs

christocracy commented 5 years ago

Are you using PHP on server?

christocracy commented 5 years ago

Also see Debugging

Run your app in XCode and observe logs:

A successful HTTP request looks like this:

✅-[TSLocationManager persistLocation:]_block_invoke INSERT: BBC487EE-7426-4577-AAC1-ED127D507F58
╔═══════════════════════════════════════════════════════════
║ -[TSHttpService flush:error:] 
╚═══════════════════════════════════════════════════════════
✅-[BackgroundTaskManager createBackgroundTask] 1
✅-[TSHttpService schedulePost:] LOCKED: BBC487EE-7426-4577-AAC1-ED127D507F58
🔵-[TSHttpService doPost:] HTTP Response: 200
✅-[TSHttpService post:error:] DESTROY: BBC487EE-7426-4577-AAC1-ED127D507F58
aaronharper123 commented 5 years ago

But no any logs are occurred .

aaronharper123 commented 5 years ago

Are you using PHP on server?

.net server

christocracy commented 5 years ago

Yes, because you haven't configured logLevel: this.bgGeo.LOG_LEVEL_VERBOSE (the default is OFF (no logs).

You'll also want to use debug: true during development.

this.bgGeo.ready({
  reset: true,  // <-- use this during development.
  debug: true,
  logLevel: this.bgGeo.LOG_LEVEL_VERBOSE
  .
  .
  .
});

See docs for #ready for note about reset: true

aaronharper123 commented 5 years ago

If i want to get all stored location then how can i get ?

christocracy commented 5 years ago

See docs for HTTP & Persistence Methods

aaronharper123 commented 5 years ago

2018-06-07 19:46:21.451140 Galio[598:184207] [TSBackgroundFetch addListener]: TSLocationManager 2018-06-07 19:46:21.451353 Galio[598:184207] [TSBackgroundFetch start]

above is my log.. i wait 1 minute but does not work. and also no console are occurred form getLocations method

aaronharper123 commented 5 years ago

when i go to background then app is started some notification but no any url fired

christocracy commented 5 years ago

Show me XCode logs of your app booting from scratch. It should look like this:

ℹ️-[TSLocationManager init] {
    activityRecognitionInterval = 10000;
    activityType = 1;
    autoSync = 1;
    autoSyncThreshold = 0;
    batchSync = 0;
    debug = 0;
    desiredAccuracy = "-2";
    desiredOdometerAccuracy = 100;
    disableElasticity = 1;
    disableLocationAuthorizationAlert = 0;
    disableMotionActivityUpdates = 0;
    disableStopDetection = 0;
    distanceFilter = 50;
    elasticityMultiplier = 1;
    enabled = 1;
    extras =     {
    };
    geofenceInitialTriggerEntry = 1;
    geofenceProximityRadius = 1000;
    geofenceTemplate = "";
    headers =     {
    };
    heartbeatInterval = 60;
    httpRootProperty = location;
    httpTimeout = 60000;
    isFirstBoot = 0;
    isMoving = 0;
    lastLocationAuthorizationStatus = 3;
    locationAuthorizationAlert =     {
        cancelButton = Cancel;
        instructions = "To use background location, you must enable '{locationAuthorizationRequest}' in the Location Services settings";
        settingsButton = Settings;
        titleWhenNotEnabled = "Background location is not enabled";
        titleWhenOff = "Location services are off";
    };
    locationAuthorizationRequest = Any;
    locationTemplate = "";
    locationTimeout = 60;
    locationsOrderDirection = ASC;
    logLevel = 5;
    logMaxDays = 3;
    maxBatchSize = "-1";
    maxDaysToPersist = 7;
    maxRecordsToPersist = "-1";
    method = POST;
    minimumActivityRecognitionConfidence = 70;
    odometer = "74632.30354112669";
    params =     {
        device =         {
            framework = ReactNative;
            manufacturer = Apple;
            model = "iPhone X";
            platform = iOS;
            uuid = "11FC8D2D-5A5E-4CC1-B3F8-D5C810817882";
            version = "11.3";
        };
    };
    pausesLocationUpdatesAutomatically = 0;
    preventSuspend = 0;
    schedule =     (
    );
    schedulerEnabled = 0;
    startOnBoot = 1;
    stationaryRadius = 25;
    stopAfterElapsedMinutes = "-1";
    stopDetectionDelay = 0;
    stopOnStationary = 0;
    stopOnTerminate = 0;
    stopTimeout = 1;
    trackingMode = 1;
    url = "http://tracker.transistorsoft.com/locations/transistor-rn";
    useSignificantChangesOnly = 0;
}
✅-[LocationDAO unlock]_block_invoke UNLOCKED ALL RECORDS
ℹ️-[GeofenceDAO init] CREATE TABLE IF NOT EXISTS geofences (id INTEGER PRIMARY KEY AUTOINCREMENT, identifier TEXT NOT NULL UNIQUE, latitude DOUBLE NOT NULL, sin_latitude DOUBLE NOT NULL, cos_latitude DOUBLE NOT NULL, longitude DOUBLE NOT NULL, sin_longitude DOUBLE NOT NULL, cos_longitude DOUBLE NOT NULL, radius DOUBLE NOT NULL, notifyOnEntry BOOLEAN NOT NULL DEFAULT 0, notifyOnExit BOOLEAN NOT NULL DEFAULT 0, notifyOnDwell BOOLEAN NOT NULL DEFAULT 0, loiteringDelay DOUBLE NOT NULL DEFAULT 0, extras TEXT)
ℹ️-[GeofenceDAO init] CREATE index IF NOT EXISTS identifier ON geofences (identifier);CREATE index IF NOT EXISTS latitude ON geofences (latitude);CREATE index IF NOT EXISTS longitude ON geofences (longitude);CREATE index IF NOT EXISTS sin_latitude ON geofences (sin_latitude);CREATE index IF NOT EXISTS cos_latitude ON geofences (cos_latitude);CREATE index IF NOT EXISTS sin_longitude ON geofences (sin_longitude);CREATE index IF NOT EXISTS cos_longitude ON geofences (cos_longitude);
🔵-[LocationManager locationManager:didChangeAuthorizationStatus:] 3
🔵-[TSLocationManager locationManager:didChangeAuthorizationStatus:] status 3
🔵-[LocationManager locationManager:didChangeAuthorizationStatus:] 3
ℹ️+[LocationAuthorization run:] status: 3
🔵-[BackgroundTaskManager locationManager:didChangeAuthorizationStatus:] 3
🔵-[LocationManager locationManager:didChangeAuthorizationStatus:] 3
ℹ️-[TSLocationManager on:success:failure:] location
2018-06-06 12:32:02.423658-0400 BGGeolocation[488:98870] [TSBackgroundFetch configure]: {
    enableHeadless = 1;
    minimumFetchInterval = 15;
    startOnBoot = 1;
    stopOnTerminate = 0;
}
ℹ️-[TSLocationManager on:success:failure:] motionchange
ℹ️-[TSLocationManager on:success:failure:] heartbeat
ℹ️-[TSLocationManager on:success:failure:] http
ℹ️-[TSGeofenceManager onGeofence:] 
ℹ️-[TSLocationManager on:success:failure:] schedule
ℹ️-[TSLocationManager on:success:failure:] activitychange
ℹ️-[TSLocationManager on:success:failure:] providerchange
ℹ️-[TSGeofenceManager onGeofencesChange:] 
ℹ️-[TSLocationManager on:success:failure:] powersavechange
ℹ️-[TSHttpService onConnectivityChange:] 
ℹ️-[TSLocationManager on:success:failure:] enabledchange
2018-06-06 12:32:02.519438-0400 BGGeolocation[488:98771] Could not inset compass from edges 9
2018-06-06 12:32:02.519487-0400 BGGeolocation[488:98771] Could not inset scale from edge 9
2018-06-06 12:32:02.539227-0400 BGGeolocation[488:98771] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2018-06-06 12:32:02.541206-0400 BGGeolocation[488:98771] [MC] Reading from public effective user settings.
2018-06-06 12:32:02.662167-0400 BGGeolocation[488:98771] [TSBackgroundFetch addListener]: RNBackgroundFetch
2018-06-06 12:32:02.662205-0400 BGGeolocation[488:98771] [TSBackgroundFetch start]
ℹ️-[TSLocationManager doStart:] trackingMode: 1
🎾-[TSGeofenceManager start] 

╔═══════════════════════════════════════════════════════════
║ -[TSHttpService finish:error:] Success: 1
╚═══════════════════════════════════════════════════════════
🎾-[SOMotionDetector startDetection] 
🔵-[TSLocationManager setPace:] 0
🎾-[TSLocationManager startUpdatingLocation] Location-services: ON
2018-06-06 12:32:02.678342-0400 BGGeolocation[488:98771] Could not inset compass from edges 9
2018-06-06 12:32:02.678379-0400 BGGeolocation[488:98771] Could not inset scale from edge 9
2018-06-06 12:32:02.690500-0400 BGGeolocation[488:98771] Could not inset compass from edges 9
2018-06-06 12:32:02.690553-0400 BGGeolocation[488:98771] Could not inset scale from edge 9

╔═══════════════════════════════════════════════════════════
║ -[TSGeofenceManager evaluateProximity:] Found 3 / 6 within 1000 m
╚═══════════════════════════════════════════════════════════
✅-[SOMotionDetector startDetection]_block_invoke Enabled M7 MotionActivity updates

📍<+45.51920826,-73.61686532> +/- 65.00m (speed -1.00 mps / course -1.00) @ 6/6/18, 12:31:49 PM GMT-04:00

╔═══════════════════════════════════════════════════════════
║ -[TSLocationManager locationManager:didUpdateLocations:] Enabled: 1 | isMoving: 0 | df: -1.0m | age: 13.7s
╚═══════════════════════════════════════════════════════════
ℹ️-[TSLocationManager locationManager:didUpdateLocations:] Received stale motionchange location.  Retrying...
ℹ️+[LocationAuthorization run:] status: 3
2018-06-06 12:32:02.989428-0400 BGGeolocation[488:98771] [TSBackgroundFetch addListener]: TSLocationManager
2018-06-06 12:32:02.989456-0400 BGGeolocation[488:98771] [TSBackgroundFetch start]
🎾-[TSLocationManager startMonitoringBackgroundFetch] BackgroundFetch: ON

╔═══════════════════════════════════════════════════════════
║ -[TSLocationManager createMotionTypeChangedHandler]_block_invoke | still/33 | isMoving: 0
╚═══════════════════════════════════════════════════════════

📍<+45.51920826,-73.61686532> +/- 65.00m (speed -1.00 mps / course -1.00) @ 6/6/18, 12:31:58 PM GMT-04:00

╔═══════════════════════════════════════════════════════════
║ -[TSLocationManager locationManager:didUpdateLocations:] Enabled: 1 | isMoving: 0 | df: -1.0m | age: 4.7s
╚═══════════════════════════════════════════════
║ -[TSLocationManager locationManager:didUpdateLocations:] Enabled: 1 | isMoving: 0 | df: -1.0m | age: 4.7s
╚══════════════════════════════════\342═════════════════════════
✅-[TSLocationManager locationManager:didUpdateLocations:] Acquired motionchange position: <+45.51920826,-73.61686532> +/- 65.00m (speed -1.00 mps / course -1.00) @ 6/6/18, 12:31:58 PM GMT-04:00
ℹ️-[TSConfig persist] 
🔵-[TSConfig incrementOdometer:] 74638.8
🔵-[TSLocationManager startMonitoringStationaryRegion:radius:] Radius: 25
🔴-[TSLocationManager stopUpdatingLocation] 
🔵-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 65.0
christocracy commented 5 years ago

Also, show me your:

$ cordova plugins
aaronharper123 commented 5 years ago

cordova-background-geolocation-lt 2.12.2 "BackgroundGeolocation" cordova-open-native-settings 1.5.1 "Native settings" cordova-plugin-actionsheet 2.3.3 "ActionSheet" cordova-plugin-advanced-http 1.11.1 "Advanced HTTP plugin" cordova-plugin-app-version 0.1.9 "AppVersion" cordova-plugin-background-fetch 5.4.1 "CDVBackgroundFetch" cordova-plugin-background-mode 0.7.2 "BackgroundMode" cordova-plugin-badge 0.8.7 "Badge" cordova-plugin-battery-status 2.0.2 "Battery" cordova-plugin-camera 4.0.3 "Camera" cordova-plugin-cocoalumberjack 0.0.4 "CocoaLumberjack" cordova-plugin-device 2.0.2 "Device" cordova-plugin-dialogs 2.0.1 "Notification" cordova-plugin-file 6.0.1 "File" cordova-plugin-file-transfer 1.7.1 "File Transfer" cordova-plugin-geolocation 4.0.1 "Geolocation" cordova-plugin-ionic-keyboard 2.0.5 "cordova-plugin-ionic-keyboard" cordova-plugin-local-notification 0.9.0-beta.3 "LocalNotification" cordova-plugin-network-information 2.0.1 "Network Information" cordova-plugin-splashscreen 5.0.2 "Splashscreen" cordova-plugin-telerik-imagepicker 2.2.0 "ImagePicker" cordova-plugin-whitelist 1.3.3 "Whitelist" cordova-sqlite-storage 2.3.2 "Cordova sqlite storage plugin" cordova.plugins.diagnostic 4.0.8 "Diagnostic" mx.ferreyra.callnumber 0.0.2 "Cordova Call Number Plugin" uk.co.workingedge.phonegap.plugin.launchnavigator 4.2.0 "Launch Navigator"

aaronharper123 commented 5 years ago

my logs. 2018-06-07 21:30:13.545611+0530 Galio[37967:381622] Apache Cordova native platform version 4.5.3 is starting. 2018-06-07 21:30:13.545909+0530 Galio[37967:381622] Multi-tasking -> Device: YES, App: YES 2018-06-07 21:30:13.647499+0530 Galio[37967:381622] Using UIWebView 2018-06-07 21:30:13.649777+0530 Galio[37967:381622] [CDVTimer][console] 0.098944ms 2018-06-07 21:30:13.650029+0530 Galio[37967:381622] [CDVTimer][handleopenurl] 0.079989ms 2018-06-07 21:30:13.652024+0530 Galio[37967:381622] [CDVTimer][intentandnavigationfilter] 1.875043ms 2018-06-07 21:30:13.652256+0530 Galio[37967:381622] [CDVTimer][gesturehandler] 0.066996ms 2018-06-07 21:30:13.652491+0530 Galio[37967:381622] CDVIonicKeyboard: resize mode 1 2018-06-07 21:30:13.653597+0530 Galio[37967:381622] CDVIonicKeyboard: WARNING!!: Keyboard plugin works better with WK 2018-06-07 21:30:13.653790+0530 Galio[37967:381622] [CDVTimer][keyboard] 1.381993ms 2018-06-07 21:30:13.676408+0530 Galio[37967:381622] [CDVTimer][splashscreen] 22.490025ms 2018-06-07 21:30:13.700014+0530 Galio[37967:381622] [CDVTimer][file] 23.450971ms 2018-06-07 21:30:13.710147+0530 Galio[37967:381622] [CDVTimer][localnotification] 9.932995ms 2018-06-07 21:30:13.710332+0530 Galio[37967:381622] [CDVTimer][localnotification] 0.007987ms 2018-06-07 21:30:13.710926+0530 Galio[37967:381622] [CDVTimer][diagnostic] 0.483036ms 2018-06-07 21:30:13.732904+0530 Galio[37967:381622] [CDVTimer][diagnostic_location] 21.847963ms 2018-06-07 21:30:13.734848+0530 Galio[37967:381683] [CoreBluetooth] XPC connection invalid 2018-06-07 21:30:13.734955+0530 Galio[37967:381622] [CDVTimer][diagnostic_bluetooth] 1.892924ms 2018-06-07 21:30:13.735172+0530 Galio[37967:381622] [CDVTimer][diagnostic_wifi] 0.074029ms 2018-06-07 21:30:13.735362+0530 Galio[37967:381622] [CDVTimer][diagnostic_camera] 0.066042ms 2018-06-07 21:30:13.735642+0530 Galio[37967:381622] [CDVTimer][diagnostic_notifications] 0.090003ms 2018-06-07 21:30:13.736325+0530 Galio[37967:381622] [CDVTimer][diagnostic_microphone] 0.349998ms 2018-06-07 21:30:13.740133+0530 Galio[37967:381622] [CDVTimer][diagnostic_contacts] 3.501058ms 2018-06-07 21:30:13.740347+0530 Galio[37967:381622] [CDVTimer][diagnostic_calendar] 0.074029ms 2018-06-07 21:30:13.740561+0530 Galio[37967:381622] [CDVTimer][diagnostic_reminders] 0.096083ms 2018-06-07 21:30:13.748948+0530 Galio[37967:381622] [CDVTimer][diagnostic_motion] 8.271933ms 2018-06-07 21:30:13.749246+0530 Galio[37967:381622] [CDVTimer][backgroundfetch] 0.161052ms 2018-06-07 21:30:13.749357+0530 Galio[37967:381622] [CDVTimer][TotalPluginStartup] 99.779010ms 2018-06-07 21:30:14.254999+0530 Galio[37967:381622] Resetting plugins due to page load. 2018-06-07 21:30:15.849400+0530 Galio[37967:381622] Finished load of: file:///Users/crestmac-2/Library/Developer/CoreSimulator/Devices/2000D920-2CF9-44C4-ABA4-9AA5C36D2F29/data/Containers/Bundle/Application/BF58DDE0-ACFC-49BA-8A5A-B57BD7359574/Galio.app/www/index.html 2018-06-07 21:30:16.008946+0530 Galio[37967:381622] Ionic Native: deviceready event fired after 1093 ms 2018-06-07 21:30:16.009116+0530 Galio[37967:381622] OPEN database: galio_database.db 2018-06-07 21:30:16.010622+0530 Galio[37967:381622] -[SQLitePlugin pluginInitialize] [Line 29] Initializing SQLitePlugin 2018-06-07 21:30:16.010994+0530 Galio[37967:381622] -[SQLitePlugin pluginInitialize] [Line 40] Detected docs path: /Users/crestmac-2/Library/Developer/CoreSimulator/Devices/2000D920-2CF9-44C4-ABA4-9AA5C36D2F29/data/Containers/Data/Application/339AEF9F-EDE8-4CF4-93D1-E4D633BC5E01/Documents 2018-06-07 21:30:16.011126+0530 Galio[37967:381622] -[SQLitePlugin pluginInitialize] [Line 44] Detected Library path: /Users/crestmac-2/Library/Developer/CoreSimulator/Devices/2000D920-2CF9-44C4-ABA4-9AA5C36D2F29/data/Containers/Data/Application/339AEF9F-EDE8-4CF4-93D1-E4D633BC5E01/Library 2018-06-07 21:30:16.011460+0530 Galio[37967:381622] -[SQLitePlugin pluginInitialize] [Line 51] no cloud sync at path: /Users/crestmac-2/Library/Developer/CoreSimulator/Devices/2000D920-2CF9-44C4-ABA4-9AA5C36D2F29/data/Containers/Data/Application/339AEF9F-EDE8-4CF4-93D1-E4D633BC5E01/Library/LocalDatabase 2018-06-07 21:30:16.011774+0530 Galio[37967:381711] -[SQLitePlugin closeNow:] [Line 203] close: db name was not open: galio_database.db 2018-06-07 21:30:16.027977+0530 Galio[37967:381622] WARN: Native: tried calling StatusBar.styleDefault, but the StatusBar plugin is not installed. 2018-06-07 21:30:16.028720+0530 Galio[37967:381622] WARN: Install the StatusBar plugin: 'ionic cordova plugin add cordova-plugin-statusbar' 2018-06-07 21:30:16.030659+0530 Galio[37967:381622] Platform ready from cordova 2018-06-07 21:30:16.030984+0530 Galio[37967:381622] TAGAARON: username: Jkko 2018-06-07 21:30:16.216757+0530 Galio[37967:381622] Aaron Header: {"_body":"{\"LocationInterval\":5,\"SMSEnable\":false,\"CheckListTime\":\"19:43\",\"LocationRange\":500,\"Status\":[{\"StatusId\":1,\"Name\":\"Pending\"},{\"StatusId\":2,\"Name\":\"Work-in-progress\"},{\"StatusId\":3,\"Name\":\"Hold\"},{\"StatusId\":4,\"Name\":\"Completed\"},{\"StatusId\":5,\"Name\":\"Call Back\"},{\"StatusId\":6,\"Name\":\"Rescheduled\"}]}","status":200,"ok":true,"statusText":"OK","headers":{"cache-control":["no-cache"],"content-length":["301"],"content-type":["application/json; charset=utf-8"],"date":["Thu"," 07 Jun 2018 16:00:15 GMT"],"expires":["-1"],"pragma":["no-cache"],"server":["Microsoft-IIS/10.0"],"x-aspnet-version":["4.0.30319"],"x-powered-by":["ASP.NET"]},"type":2,"url":"http://property.zoomi.in:86/api/User/Settings"} 2018-06-07 21:30:16.216926+0530 Galio[37967:381622] {"LocationInterval":5,"SMSEnable":false,"CheckListTime":"19:43","LocationRange":500,"Status":[{"StatusId":1,"Name":"Pending"},{"StatusId":2,"Name":"Work-in-progress"},{"StatusId":3,"Name":"Hold"},{"StatusId":4,"Name":"Completed"},{"StatusId":5,"Name":"Call Back"},{"StatusId":6,"Name":"Rescheduled"}]} 2018-06-07 21:30:16.217277+0530 Galio[37967:381622] a: 1.0.0 2018-06-07 21:30:16.217619+0530 Galio[37967:381740] -[SQLitePlugin openNow:] [Line 141] open full db path: /Users/crestmac-2/Library/Developer/CoreSimulator/Devices/2000D920-2CF9-44C4-ABA4-9AA5C36D2F29/data/Containers/Data/Application/339AEF9F-EDE8-4CF4-93D1-E4D633BC5E01/Library/LocalDatabase/galio_database.db 2018-06-07 21:30:16.228070+0530 Galio[37967:381740] -[SQLitePlugin openNow:] [Line 168] Good news: SQLite is thread safe! 2018-06-07 21:30:16.525682+0530 Galio[37967:381622] WARN: Unknown property: at 2018-06-07 21:30:16.525902+0530 Galio[37967:381622] OPEN database: galio_database.db - OK 2018-06-07 21:30:16.527348+0530 Galio[37967:381712] [local-notification] Next trigger at: Fri Jun 8 19:43:00 2018 2018-06-07 21:30:17.551209+0530 Galio[37967:381622] [TSBackgroundFetch addListener]: TSLocationManager 2018-06-07 21:30:17.551364+0530 Galio[37967:381622] [TSBackgroundFetch start]

christocracy commented 5 years ago
aaronharper123 commented 5 years ago

yes of course , i will update my code..

aaronharper123 commented 5 years ago
this.platform.ready().then(() => {
                  this.bgGeo = (<any>window).BackgroundGeolocation;
                  this.onDeviceReady.bind(this)
                });
onDeviceReady() {

    this.bgGeo.on('location', this.onLocation.bind(this));
    this.bgGeo.on('motionchange', this.onMotionChange.bind(this));
    this.bgGeo.on('activitychange', this.onActivityChange.bind(this));
    this.bgGeo.on('geofence', this.onGeofence.bind(this));
    this.bgGeo.on('http', this.onHttpSuccess.bind(this), this.onHttpFailure.bind(this));

    // BackgroundGeoLocation is highly configurable.
    this.bgGeo.ready({
        // Geolocation config
        desiredAccuracy: 0,
        distanceFilter: 0,
        stationaryRadius: 0,
        interval: 3000,
        // Activity Recognition config
        activityRecognitionInterval: 3000,
        stopTimeout: 5,
        // Application config
        debug: true,  // <-- Debug sounds & notifications.
        reset: true,
        logLevel: this.bgGeo.LOG_LEVEL_VERBOSE,
        stopOnTerminate: false,
        startOnBoot: true,
        // HTTP / SQLite config
        url: "http://property.zoomi.in:86/api/User/UserTracking",
        headers: {  // <-- Optional HTTP headers
            "Content-Type": "application/json"
        },
        params: {   // <-- Optional HTTP params
          "UserId": 4,
          "LocationData": [
          {
            "Lat": 'xyz',
            "Long": 'xyz',
            "Date": 'xyz',
            "BatteryPerc": 44
          }
          ]
        },
        method: "POST",
        autoSync: true,
        maxDaysToPersist: 3,

    }, function(state) {
        // This callback is executed when the plugin is ready to use.
        console.log("BackgroundGeolocation ready: ", state);
        // this.bgGeo.start();
    });

  }

  onLocation(location, taskId) {
    console.log('- location: ', location);
    this.bgGeo.getLocations(function(locations) {
      console.log("locations: ", locations);
});
    this.bgGeo.finish(taskId);
  }
  onMotionChange(isMoving, location, taskId) {
    console.log('- motionchange: ', isMoving, location);
    this.bgGeo.finish(taskId);
  }
  onActivityChange(activity) {
    console.log('- activitychange: ', activity);
  }
  onGeofence(params, taskId) {
    console.log('- geofence: ', params);
    this.bgGeo.finish(taskId);
  }
  onHttpSuccess(response) {
    console.log('- http success: ', response);
  }
  onHttpFailure(response) {
    console.log('- http failure: ', response);
  }
aaronharper123 commented 5 years ago

please update me , i have to complete my tracking work within tomorrow

christocracy commented 5 years ago

Why have you commented-out this:

// this.bgGeo.start();

un-comment that. you need to tell the plugin to #start

aaronharper123 commented 5 years ago

i am calling start function from button click and to stop from stop button click

christocracy commented 5 years ago

btw, multi-line code-blocks require 3-backticks -- not one.

christocracy commented 5 years ago

Do you hear the plugin's debug sounds?

aaronharper123 commented 5 years ago

yes i heared the sound when plugin activate and also i heared the sound when plugin fires notification

christocracy commented 5 years ago

In Javascript console, show me the result of the following:

> bg = window.BackgroundGeolocation;
> await bg.getState();
christocracy commented 5 years ago

and this, also in Javascript console (will be a large amount of text):

>await bg.getLog()
aaronharper123 commented 5 years ago

screen shot 2018-06-07 at 9 56 29 pm

nothing happened

christocracy commented 5 years ago

christocracy commented 5 years ago

When I say "Javascript Console", I mean the Safari Javascript Console, not XCode. You can't talk to Javascript in XCode.

aaronharper123 commented 5 years ago

Soory for that sir....

screen shot 2018-06-07 at 10 25 10 pm screen shot 2018-06-07 at 10 25 44 pm

aaronharper123 commented 5 years ago

here there are two snap, please look at that

christocracy commented 5 years ago

As you can see, getState show logLevel: 0. You are not configuring the plugin correctly.

Also, your #url is blank.

aaronharper123 commented 5 years ago

but i add url and you can see above

aaronharper123 commented 5 years ago

i configure the plugin which you can see above where is my mistake , please tell me

christocracy commented 5 years ago

In fact, you're NOT EVEN CALLING onDeviceReady!!!

this.platform.ready().then(() => {
                  this.bgGeo = (<any>window).BackgroundGeolocation;
                  //this.onDeviceReady.bind(this);  // <--------- WTF?
                  this.onDeviceReady();      // <--------- LIKE THIS!
                });
aaronharper123 commented 5 years ago

ok then i simply put this.onDeviceReady(); when plugin is ready , i will update you soon

aaronharper123 commented 5 years ago

please see my logs...

` ╔═══════════════════════════════════════════════════════════ ║ -[TSLocationManager start] ╚═══════════════════════════════════════════════════════════ ℹ️-[TSLocationManager doStart:] trackingMode: 1 ℹ️-[TSConfig persist] 🎾-[TSGeofenceManager start]

╔═══════════════════════════════════════════════════════════ ║ -[TSHttpService flush:error:] ╚═══════════════════════════════════════════════════════════ ✅-[BackgroundTaskManager createBackgroundTask] 3 ✅-[TSHttpService schedulePost:] LOCKED: 6AE0D743-366A-4B71-8B11-1C9BBADEE0EA 🔵-[TSLocationManager setPace:] 0 🎾-[TSLocationManager startUpdatingLocation] Location-services: ON ℹ️+[LocationAuthorization run:] status: 3

📍<+37.33793145,-122.08422750> +/- 5.00m (speed 33.36 mps / course 305.51) @ 6/7/18, 10:42:12 PM India Standard Time

╔═══════════════════════════════════════════════════════════ ║ -[TSLocationManager locationManager:didUpdateLocations:] Enabled: 1 | isMoving: 0 | df: -1.0m | age: 105.1s ╚═══════════════════════════════════════════════════════════ ℹ️-[TSLocationManager locationManager:didUpdateLocations:] Received stale motionchange location. Retrying... 🎾-[TSLocationManager startMonitoringBackgroundFetch] BackgroundFetch: ON 2018-06-07 22:43:57.778816+0530 Galio[41045:427145] [TSBackgroundFetch addListener]: TSLocationManager 2018-06-07 22:43:57.779468+0530 Galio[41045:427145] [TSBackgroundFetch start] 2018-06-07 22:43:57.784374+0530 Galio[41045:427145] - location: {"coords":{"speed":33.36,"longitude":-122.0842275,"floor":0,"latitude":37.33793145,"accuracy":5,"altitude_accuracy":-1,"altitude":0,"heading":305.51},"sample":true,"extras":{},"is_moving":false,"odometer":262255.7,"uuid":"B296B9CD-53A8-4710-B4E9-A1A510ED32D2","activity":{"type":"unknown","confidence":100},"battery":{"level":-1,"is_charging":false},"timestamp":"2018-06-07T17:12:12.703Z"} ⚠️-[TSHttpService doPost:] HTTP ERROR: 404


✅-[TSHttpService post:error:] UNLOCKED: 6AE0D743-366A-4B71-8B11-1C9BBADEE0EA

╔═══════════════════════════════════════════════════════════ ║ -[TSHttpService finish:error:] Success: 0 ╚═══════════════════════════════════════════════════════════ 2018-06-07 22:43:57.807939+0530 Galio[41045:427145] - http failure: [object Object] ✅-[BackgroundTaskManager stopBackgroundTask:]_block_invoke 3 OF ( 3 )

📍<+37.36324345,-122.12188572> +/- 5.00m (speed 34.09 mps / course 312.89) @ 6/7/18, 10:43:58 PM India Standard Time

╔═══════════════════════════════════════════════════════════ ║ -[TSLocationManager locationManager:didUpdateLocations:] Enabled: 1 | isMoving: 0 | df: -1.0m | age: 0.0s ╚═══════════════════════════════════════════════════════════ ✅-[TSLocationManager locationManager:didUpdateLocations:] Acquired motionchange position: <+37.36324345,-122.12188572> +/- 5.00m (speed 34.09 mps / course 312.89) @ 6/7/18, 10:43:58 PM India Standard Time 🔵-[TSLocationManager startMonitoringStationaryRegion:radius:] Radius: 25 🔴-[TSLocationManager stopUpdatingLocation] 🔵-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 5.0 🎾-[TSLocationManager startMonitoringSignificantLocationChanges] ✅-[TSLocationManager persistLocation:]_block_invoke INSERT: 02F2EF7C-E0A3-458E-91B8-E9343DDC489F

╔═══════════════════════════════════════════════════════════ ║ -[TSHttpService flush:error:] ╚═══════════════════════════════════════════════════════════ ✅-[BackgroundTaskManager createBackgroundTask] 4 ✅-[TSHttpService schedulePost:] LOCKED: 6AE0D743-366A-4B71-8B11-1C9BBADEE0EA 2018-06-07 22:43:58.746568+0530 Galio[41045:427145] - motionchange: false [object Object] 2018-06-07 22:43:58.747085+0530 Galio[41045:427145] - location: {"coords":{"speed":34.09,"longitude":-122.12188572,"floor":0,"latitude":37.36324345,"accuracy":5,"altitude_accuracy":-1,"altitude":0,"heading":312.89},"extras":{},"is_moving":false,"event":"motionchange","odometer":262255.7,"uuid":"02F2EF7C-E0A3-458E-91B8-E9343DDC489F","activity":{"type":"unknown","confidence":100},"battery":{"level":-1,"is_charging":false},"timestamp":"2018-06-07T17:13:58.705Z"} ⚠️-[TSHttpService doPost:] HTTP ERROR: 404


✅-[TSHttpService post:error:] UNLOCKED: 6AE0D743-366A-4B71-8B11-1C9BBADEE0EA

╔═══════════════════════════════════════════════════════════ ║ -[TSHttpService finish:error:] Success: 0 ╚═══════════════════════════════════════════════════════════ 2018-06-07 22:43:58.789908+0530 Galio[41045:427145] - http failure: [object Object] ✅-[BackgroundTaskManager stopBackgroundTask:]_block_invoke 4 OF ( 4 ) 🔵-[TSLocationManager locationManager:didExitRegion:] Exit stationary region 🔵-[TSLocationManager setPace:] 1 ℹ️-[TSConfig persist] 🎾-[SOMotionDetector startShakeDetection:] sample-rate: 0.2 | M7 DISABLED 🎾-[TSLocationManager startUpdatingLocation] Location-services: ON ℹ️+[LocationAuthorization run:] status: 3 2018-06-07 22:44:06.755141+0530 Galio[41045:427145] - location: {"coords":{"speed":32.89,"longitude":-122.12441747,"floor":0,"latitude":37.36447237,"accuracy":5,"altitude_accuracy":-1,"altitude":0,"heading":291.45},"sample":true,"extras":{},"is_moving":true,"odometer":262255.7,"uuid":"B9F8EC40-594C-4EA2-A823-2D7049285342","activity":{"type":"unknown","confidence":100},"battery":{"level":-1,"is_charging":false},"timestamp":"2018-06-07T17:14:06.715Z"}

📍<+37.36457081,-122.12476867> +/- 5.00m (speed 33.08 mps / course 288.63) @ 6/7/18, 10:44:07 PM India Standard Time

╔═══════════════════════════════════════════════════════════ ║ -[TSLocationManager locationManager:didUpdateLocations:] Enabled: 1 | isMoving: 1 | df: -1.0m | age: 0.0s ╚═══════════════════════════════════════════════════════════ ✅-[TSLocationManager locationManager:didUpdateLocations:] Acquired motionchange position: <+37.36457081,-122.12476867> +/- 5.00m (speed 33.08 mps / course 288.63) @ 6/7/18, 10:44:07 PM India Standard Time 🎾-[TSLocationManager startUpdatingLocation] Location-services: ON 🔵-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 5.0 ℹ️-[TSConfig persist] 🔵-[TSConfig incrementOdometer:] 262550.5 ✅-[TSLocationManager persistLocation:]_block_invoke INSERT: D2B10116-5AAB-49F5-AC96-544D84561529

╔═══════════════════════════════════════════════════════════ ║ -[TSHttpService flush:error:] ╚═══════════════════════════════════════════════════════════ ✅-[BackgroundTaskManager createBackgroundTask] 5 ✅-[TSHttpService schedulePost:] LOCKED: 6AE0D743-366A-4B71-8B11-1C9BBADEE0EA ℹ️+[LocationAuthorization run:] status: 3 2018-06-07 22:44:07.747059+0530 Galio[41045:427145] - motionchange: true [object Object] 2018-06-07 22:44:07.747263+0530 Galio[41045:427145] - location: {"coords":{"speed":33.08,"longitude":-122.12476867,"floor":0,"latitude":37.36457081,"accuracy":5,"altitude_accuracy":-1,"altitude":0,"heading":288.63},"extras":{},"is_moving":true,"event":"motionchange","odometer":262550.5,"uuid":"D2B10116-5AAB-49F5-AC96-544D84561529","activity":{"type":"unknown","confidence":100},"battery":{"level":-1,"is_charging":false},"timestamp":"2018-06-07T17:14:07.697Z"} ⚠️-[TSHttpService doPost:] HTTP ERROR: 404


✅-[TSHttpService post:error:] UNLOCKED: 6AE0D743-366A-4B71-8B11-1C9BBADEE0EA

╔═══════════════════════════════════════════════════════════ ║ -[TSHttpService finish:error:] Success: 0 ╚═══════════════════════════════════════════════════════════ 2018-06-07 22:44:07.792229+0530 Galio[41045:427145] - http failure: [object Object] ✅-[BackgroundTaskManager stopBackgroundTask:]_block_invoke 5 OF ( 5 )

📍<+37.36465673,-122.12512859> +/- 5.00m (speed 33.13 mps / course 285.82) @ 6/7/18, 10:44:08 PM India Standard Time

╔═══════════════════════════════════════════════════════════ ║ -[TSLocationManager locationManager:didUpdateLocations:] Enabled: 1 | isMoving: 1 | df: 0.0m | age: 0.0s ╚═══════════════════════════════════════════════════════════ 🔵-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 5.0 ℹ️-[TSConfig persist] 🔵-[TSConfig incrementOdometer:] 262583.8 ✅-[TSLocationManager persistLocation:]_block_invoke INSERT: ED571AD4-5A94-4650-8C89-EB5DD43A342F

╔═══════════════════════════════════════════════════════════ ║ -[TSHttpService flush:error:] ╚═══════════════════════════════════════════════════════════ ✅-[BackgroundTaskManager createBackgroundTask] 6 2018-06-07 22:44:08.713589+0530 Galio[41045:427145] - location: {"coords":{"speed":33.13,"longitude":-122.12512859,"floor":0,"latitude":37.36465673,"accuracy":5,"altitude_accuracy":-1,"altitude":0,"heading":285.82},"extras":{},"is_moving":true,"odometer":262583.8,"uuid":"ED571AD4-5A94-4650-8C89-EB5DD43A342F","activity":{"type":"unknown","confidence":100},"battery":{"level":-1,"is_charging":false},"timestamp":"2018-06-07T17:14:08.698Z"} ✅-[TSHttpService schedulePost:] LOCKED: 6AE0D743-366A-4B71-8B11-1C9BBADEE0EA ⚠️-[TSHttpService doPost:] HTTP ERROR: 404


2018-06-07 22:44:08.776199+0530 Galio[41045:427145] - http failure: [object Object] ✅-[TSHttpService post:error:] UNLOCKED: 6AE0D743-366A-4B71-8B11-1C9BBADEE0EA

╔═══════════════════════════════════════════════════════════ ║ -[TSHttpService finish:error:] Success: 0 ╚════════════════════════════════════════════════════════`

christocracy commented 5 years ago

This can be closed. Clearly the "url is now being called". Your server is saying "404".

⚠️-[TSHttpService doPost:] HTTP ERROR: 404

aaronharper123 commented 5 years ago

is this plugin work after app is terminated ??

aaronharper123 commented 5 years ago

why plugin update location at every seconds ? i want to get location at every minutes , what can i d for . ?

christocracy commented 5 years ago

is this plugin work after app is terminated ??

Yes, of course. #stopOnTerminate

why plugin update location at every seconds ? i want to get location at every minutes , what can i d for . ?

#distanceFilter

aaronharper123 commented 5 years ago

can i give distanceFilter = 200m and interval = 120000 then .. this plugin is updates at 2 minutes ?

christocracy commented 5 years ago

There's no such config option #interval. I know you're using Mauron85's version (I see you posting issues there). Mauron85's version is a fork of my original open-source project from ~4 years ago. You can see it's still licensed to Transistor Software, that's me.

It's #locationUpdateInterval and it's Android-only.

iOS is strictly distance-based. You can only think in terms of distanceFilter for iOS.

aaronharper123 commented 5 years ago

i put distanceFilter = 100m and i run project on my simulator and my pc is stay at one side, but location updates at every 5-6 seconds how is this possible with distanceFilter 100m?

christocracy commented 5 years ago

If you need to compose a custom template for your server, see HTTP Features

However, if your server is expecting timstamp in some particular format, you can't change that:

{"Message":"The conversion of a datetimeoffset data type to a datetime data type resulted in an out-of-range value.\r\nThe statement has been terminated."}

This plugin posts timestamp in ISO-8601 UTC format, eg: "2018-06-07T04:31:54.123Z". Your server will have to be modified to consume this timestamp format.

aaronharper123 commented 5 years ago

This plugin posts timestamp in ISO-8601 UTC format, eg: "2018-06-07T04:31:54.123Z". Your server will have to be modified to consume this timestamp format.

ok i will change as per needed

christocracy commented 5 years ago

Show me bg.getState() from Javascript Console again.

aaronharper123 commented 5 years ago

please see my snap and it says can't find variable: bg

screen shot 2018-06-07 at 11 17 33 pm

christocracy commented 5 years ago

It's assumed that you know that you must create your own var reference to window.BackgroundGeolocation in console!

>bg = window.BackgroundGeolocation
> await bg.getState()
aaronharper123 commented 5 years ago

screen shot 2018-06-07 at 11 21 58 pm screen shot 2018-06-07 at 11 22 39 pm

christocracy commented 5 years ago

distanceFilter is clearly 100.

What are you simulating location with? Are you using "Freeway Drive"?

aaronharper123 commented 5 years ago

yes sir, i am using Freeway Drive