{"action":"created","issue":{"url":"https://api.github.com/repos/pmwisdom/cordova-background-geolocation-services/issues/20","repository_url":"https://api.github.com/repos/pmwisdom/cordova-background-geolocation-services","labels_url":"https://api.github.com/repos/pmwisdom/cordova-background-geolocation-services/issues/20/labels{/name}","comments_url":"https://api.github.com/repos/pmwisdom/cordova-background-geolocation-services/issues/20/comments","events_url":"https://api.github.com/repos/pmwisdom/cordova-background-geolocation-services/issues/20/events","html_url":"https://github.com/pmwisdom/cordova-background-geolocation-services/issues/20","id":157187199,"number":20,"title":"Lock screen tracking","user":{"login":"3rror404","id":1102402,"avatar_url":"https://avatars.githubusercontent.com/u/1102402?v=3","gravatar_id":"","url":"https://api.github.com/users/3rror404","html_url":"https://github.com/3rror404","followers_url":"https://api.github.com/users/3rror404/followers","following_url":"https://api.github.com/users/3rror404/following{/other_user}","gists_url":"https://api.github.com/users/3rror404/gists{/gist_id}","starred_url":"https://api.github.com/users/3rror404/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/3rror404/subscriptions","organizations_url":"https://api.github.com/users/3rror404/orgs","repos_url":"https://api.github.com/users/3rror404/repos","events_url":"https://api.github.com/users/3rror404/events{/privacy}","received_events_url":"https://api.github.com/users/3rror404/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":15,"created_at":"2016-05-27T11:31:52Z","updated_at":"2016-06-04T14:37:41Z","closed_at":null,"body":"I'm having some issues with tracking when the device is locked and the app is in the foreground on iOS (not tested on Android).\r\n\r\nI have been experiencing this in my own app and thought it was perhaps an issue with my own code but I see the same issue when using your demo code in a fresh Phonegap app. Often I do not receive location updates or notifications. When the app resumes I see one \"We got an BG update ....\" console log. Some times it will work perfectly but I can't work out what is causing the inconsistent behaviour.  \r\n\r\nLocations seem to work perfectly when the app is pushed into the background with the home button before locking the device.\r\n\r\nI am successfully acquiring a location before locking the device.\r\n\r\nThis is my test index.js\r\n\r\n```\r\nvar app = {\r\n    // Application Constructor\r\n    initialize: function() {\r\n        this.bindEvents();\r\n    },\r\n    // Bind Event Listeners\r\n    //\r\n    // Bind any events that are required on startup. Common events are:\r\n    // 'load', 'deviceready', 'offline', and 'online'.\r\n    bindEvents: function() {\r\n        document.addEventListener('deviceready', this.onDeviceReady, false);\r\n    },\r\n    // deviceready Event Handler\r\n    //\r\n    // The scope of 'this' is the event. In order to call the 'receivedEvent'\r\n    // function, we must explicitly call 'app.receivedEvent(...);'\r\n    onDeviceReady: function() {\r\n        app.receivedEvent('deviceready');\r\n    },\r\n    // Update DOM on a Received Event\r\n    receivedEvent: function(id) {\r\n        var parentElement = document.getElementById(id);\r\n        var listeningElement = parentElement.querySelector('.listening');\r\n        var receivedElement = parentElement.querySelector('.received');\r\n\r\n        listeningElement.setAttribute('style', 'display:none;');\r\n        receivedElement.setAttribute('style', 'display:block;');\r\n\r\n        console.log('Received Event: ' + id);\r\n        \r\n        var output = document.getElementById(\"output\");\r\n        output.textContent = \"Getting position...\";\r\n        \r\n        //Make sure to get at least one GPS coordinate in the foreground before starting background services\r\n        navigator.geolocation.getCurrentPosition(onSuccess);\r\n        \r\n        function onSuccess() {\r\n            output.textContent = \"Position aquired.\";\r\n        }\r\n\r\n        //Get plugin\r\n        var bgLocationServices =  window.plugins.backgroundLocationServices;\r\n\r\n        //Congfigure Plugin\r\n        bgLocationServices.configure({\r\n            //Both\r\n            desiredAccuracy: 20, // Desired Accuracy of the location updates (lower means more accurate but more battery consumption)\r\n            distanceFilter: 5, // (Meters) How far you must move from the last point to trigger a location update\r\n            debug: true, // <-- Enable to show visual indications when you receive a background location update\r\n            interval: 9000, // (Milliseconds) Requested Interval in between location updates.\r\n            //Android Only\r\n            notificationTitle: 'BG Plugin', // customize the title of the notification\r\n            notificationText: 'Tracking', //customize the text of the notification\r\n            fastestInterval: 5000, // <-- (Milliseconds) Fastest interval your app / server can handle updates\r\n            useActivityDetection: true // Uses Activitiy detection to shut off gps when you are still (Greatly enhances Battery Life)\r\n\r\n        });\r\n\r\n        //Register a callback for location updates, this is where location objects will be sent in the background\r\n        bgLocationServices.registerForLocationUpdates(function(location) {\r\n            console.log(\"We got an BG Update\" + JSON.stringify(location));\r\n        }, function(err) {\r\n            console.log(\"Error: Didnt get an update\", err);\r\n        });\r\n\r\n        //Register for Activity Updates (ANDROID ONLY)\r\n        //Uses the Detected Activies API to send back an array of activities and their confidence levels\r\n        //See here for more information: //https://developers.google.com/android/reference/com/google/android/gms/location/DetectedActivity\r\n        bgLocationServices.registerForActivityUpdates(function(acitivites) {\r\n            console.log(\"We got an BG Update\" + activities);\r\n        }, function(err) {\r\n            console.log(\"Error: Something went wrong\", err);\r\n        });\r\n\r\n        //Start the Background Tracker. When you enter the background tracking will start, and stop when you enter the foreground.\r\n        bgLocationServices.start();\r\n\r\n\r\n        ///later, to stop\r\n        //bgLocationServices.stop();\r\n    }\r\n};\r\n```\r\n\r\nHere is an example log from a time when tracking did not work:\r\n\r\n```\r\n2016-05-27 13:05:11.012 Hello World[3739:1422193] Apache Cordova native platform version 3.9.2 is starting.\r\n2016-05-27 13:05:11.013 Hello World[3739:1422193] Multi-tasking -> Device: YES, App: YES\r\n2016-05-27 13:05:11.029 Hello World[3739:1422193] Unlimited access to network resources\r\n2016-05-27 13:05:11.042 Hello World[3739:1422193] \r\n\r\nStarted backup to iCloud! Please be careful.\r\nYour application might be rejected by Apple if you store too much data.\r\nFor more information please read \"iOS Data Storage Guidelines\" at:\r\nhttps://developer.apple.com/icloud/documentation/data-storage/\r\nTo disable web storage backup to iCloud, set the BackupWebStorage preference to \"local\" in the Cordova config.xml file\r\n\r\n2016-05-27 13:05:11.496 Hello World[3739:1422193] Resetting plugins due to page load.\r\n2016-05-27 13:05:11.637 Hello World[3739:1422193] Finished load of: file:///var/containers/Bundle/Application/11D795EC-B0CD-4025-9E96-862A74025B35/Hello%20World.app/www/index.html\r\n2016-05-27 13:05:11.741 Hello World[3739:1422193] THREAD WARNING: ['Geolocation'] took '21.319092' ms. Plugin should use a background thread.\r\n2016-05-27 13:05:11.774 Hello World[3739:1422193] [LocationServices] - --------------------------------------------------------\r\n2016-05-27 13:05:11.775 Hello World[3739:1422193] [LocationServices] -    Configuration Success\r\n2016-05-27 13:05:11.776 Hello World[3739:1422193] [LocationServices] -        Distance Filter     5.0\r\n2016-05-27 13:05:11.776 Hello World[3739:1422193] [LocationServices] -        Desired Accuracy    10.0\r\n2016-05-27 13:05:11.779 Hello World[3739:1422193] [LocationServices] -        Activity Type       CLActivityType\r\n2016-05-27 13:05:11.779 Hello World[3739:1422193] [LocationServices] -        Update Interval     5.0\r\n2016-05-27 13:05:11.779 Hello World[3739:1422193] [LocationServices] - --------------------------------------------------------\r\n2016-05-27 13:05:11.780 Hello World[3739:1422193] [LocationServices] - Started\r\n2016-05-27 13:05:11.811 Hello World[3739:1422193] THREAD WARNING: ['BackgroundLocationServices'] took '30.446045' ms. Plugin should use a background thread.\r\n2016-05-27 13:05:11.815 Hello World[3739:1422193] [LocationServices] - registerForLocationUpdates\r\n2016-05-27 13:05:11.817 Hello World[3739:1422193] ERROR: Method 'registerForActivityUpdates:' not defined in Plugin 'BackgroundLocationServices'\r\n2016-05-27 13:05:11.817 Hello World[3739:1422193] -[CDVCommandQueue executePending] [Line 159] FAILED pluginJSON = [\"BackgroundLocationServices565512988\",\"BackgroundLocationServices\",\"registerForActivityUpdates\",[]]\r\n2016-05-27 13:05:16.318 Hello World[3739:1422193] [LocationServices] - App Will Resign. Enabled? true\r\n2016-05-27 13:05:16.320 Hello World[3739:1422193] [LocationServices] - Starting Location Updates!\r\n2016-05-27 13:05:16.409 Hello World[3739:1422193] [LocationServices] - App Suspended. Enabled? true\r\n2016-05-27 13:05:16.412 Hello World[3739:1422193] [LocationServices] - Starting Location Updates!\r\n2016-05-27 13:05:16.425 Hello World[3739:1422193] [LocationServices] - Got location update\r\n\r\nAFTER RESUME…\r\n\r\n2016-05-27 13:05:39.831 Hello World[3739:1422193] [LocationServices] - sync called\r\n2016-05-27 13:05:39.832 Hello World[3739:1422193] [LocationServices] - locationArray has no entries\r\n2016-05-27 13:05:39.832 Hello World[3739:1422193] [LocationServices] - Stopped Location Updates After 2.0\r\n2016-05-27 13:05:39.832 Hello World[3739:1422193] [LocationServices] - restartUpdates called\r\n2016-05-27 13:05:39.834 Hello World[3739:1422193] [LocationServices] - Starting Location Updates!\r\n2016-05-27 13:05:40.032 Hello World[3739:1422193] [LocationServices] - App Resumed\r\n2016-05-27 13:05:40.037 Hello World[3739:1422193] [LocationServices] - Stopping Location Updates!\r\n2016-05-27 13:05:40.083 Hello World[3739:1422193] [LocationServices] - Got location update\r\n2016-05-27 13:05:40.085 Hello World[3739:1422193] [LocationServices] - Got location update\r\n2016-05-27 13:05:42.084 Hello World[3739:1422193] [LocationServices] - sync called\r\n2016-05-27 13:05:42.106 Hello World[3739:1422193] [LocationServices] - bestLocation: {Optional(<+53.79545628,-1.54111949> +/- 65.00m (speed -1.00 mps / course -1.00) @ 27/05/2016, 13:05:40 British Summer Time)}\r\n\r\nSIMILAR TO BELOW IS REPEATED EVERY 2 SECONDS...\r\n\r\n2016-05-27 13:10:22.747 Hello World[3745:1424146] [LocationServices] - Got Location Update:  { 53.7954899420689 - -1.54113312728304 }  Accuracy: 65.0\r\n2016-05-27 13:10:22.747 Hello World[3745:1424146] [LocationServices] - Sending Notification\r\n2016-05-27 13:10:22.749 Hello World[3745:1424146] [LocationServices] - Stopped Location Updates After 2.0\r\n2016-05-27 13:10:25.370 Hello World[3745:1424146] [LocationServices] - App Resumed\r\n2016-05-27 13:10:25.370 Hello World[3745:1424146] [LocationServices] - Stopping Location Updates!\r\n2016-05-27 13:10:25.374 Hello World[3745:1424146] [LocationServices] - Got location update\r\n2016-05-27 13:10:27.375 Hello World[3745:1424146] [LocationServices] - sync called\r\n2016-05-27 13:10:27.378 Hello World[3745:1424146] [LocationServices] - bestLocation: {Optional(<+53.79550998,-1.54116128> +/- 65.00m (speed -1.00 mps / course -1.00) @ 27/05/2016, 13:10:25 British Summer Time)}\r\n```"},"comment":{"url":"https://api.github.com/repos/pmwisdom/cordova-background-geolocation-services/issues/comments/223759013","html_url":"https://github.com/pmwisdom/cordova-background-geolocation-services/issues/20#issuecomment-223759013","issue_url":"https://api.github.com/repos/pmwisdom/cordova-background-geolocation-services/issues/20","id":223759013,"user":{"login":"pmwisdom","id":6887500,"avatar_url":"https://avatars.githubusercontent.com/u/6887500?v=3","gravatar_id":"","url":"https://api.github.com/users/pmwisdom","html_url":"https://github.com/pmwisdom","followers_url":"https://api.github.com/users/pmwisdom/followers","following_url":"https://api.github.com/users/pmwisdom/following{/other_user}","gists_url":"https://api.github.com/users/pmwisdom/gists{/gist_id}","starred_url":"https://api.github.com/users/pmwisdom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pmwisdom/subscriptions","organizations_url":"https://api.github.com/users/pmwisdom/orgs","repos_url":"https://api.github.com/users/pmwisdom/repos","events_url":"https://api.github.com/users/pmwisdom/events{/privacy}","received_events_url":"https://api.github.com/users/pmwisdom/received_events","type":"User","site_admin":false},"created_at":"2016-06-04T14:37:41Z","updated_at":"2016-06-04T14:37:41Z","body":"That issue on android has already been discussed, please search for it, or create a new issue for it, don't hijack this one.\n\n\nThe swift message has nothing to do with not building to your phone, press cancel on the dialog and it will not convert, I will fix that annoyance in a future release. "}}
{"actor":{"display_login":"pmwisdom"}}