{"action":"created","issue":{"url":"https://api.github.com/repos/transistorsoft/nativescript-background-geolocation-lt/issues/28","repository_url":"https://api.github.com/repos/transistorsoft/nativescript-background-geolocation-lt","labels_url":"https://api.github.com/repos/transistorsoft/nativescript-background-geolocation-lt/issues/28/labels{/name}","comments_url":"https://api.github.com/repos/transistorsoft/nativescript-background-geolocation-lt/issues/28/comments","events_url":"https://api.github.com/repos/transistorsoft/nativescript-background-geolocation-lt/issues/28/events","html_url":"https://github.com/transistorsoft/nativescript-background-geolocation-lt/issues/28","id":185898920,"number":28,"title":"Events fire multiple times. Duplicated location UUIDs","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":[{"id":388138910,"url":"https://api.github.com/repos/transistorsoft/nativescript-background-geolocation-lt/labels/invalid","name":"invalid","color":"e6e6e6","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":36,"created_at":"2016-10-28T11:19:23Z","updated_at":"2016-11-30T16:18:01Z","closed_at":"2016-11-30T15:05:35Z","body":"On Android when the app is quit with the back button and then reopened batch syncs will fire multiple times.\n\nThe first time the app is run sync will fire once.\nAfter exiting with the back button and resuming, if sync is called it will fire twice.\nAfter exiting and resuming again, sync will fire three times\netc.\n\nI've also just notice in the logs that locations are logged multiple times too with the same uuid.\n\nI can reproduce this in your demo app quite easily.\n\nHere are the modified parts:\n\nmap-view-model.ts\n\n```\nexport class MapModel extends observable.Observable {\n\n...\n\nprivate getConfig() {\n    var config = {};\n    if (Settings.hasKey('config')) {\n      console.log(\"using custom config\");\n      config = JSON.parse(Settings.getString('config'));\n    } else {\n      console.log(\"using default config\");\n      // Fetch default config with overrides.\n      config = SettingsViewModel.getDefaultConfig({\n        license: \"5647026b5a15ced50fcd3adcb2b743ab32abf2374c40d0aff875e53b15f93b60\",\n        url: '**SOME_URL**',\n        params: {\n          device: {\n            platform: Platform.device.os,\n            manufacturer: Platform.device.manufacturer,\n            model: Platform.device.model,\n            version: Platform.device.osVersion,\n            uuid: Platform.device.uuid\n          }\n        },\n        autoSync: false, // ADDED\n        batchSync: true, //  ADDED\n        maxBatchSize: -1 // ADDED\n      });\n      // Cache current settings\n      Settings.setString('config', JSON.stringify(config));\n    }\n    return config;\n  }\n\n...\n\npublic onHttp(response:any) {\n    console.info('[js] http: ', JSON.stringify(response));\n  }\n\n...\n\n  public sync() {\n    BackgroundGeolocation.sync(function() {\n      console.log(\"Sync successful\");\n    }, function(errorMessage) {\n        console.warn('Sync FAILURE: ', errorMessage);\n    });\n  }\n\n...\n\n}\n```\n\nmain-page.xml\n\n```\n<!-- somewhere on the page... -->\n<Button id=\"btnSync\" text=\"Sync\" class=\"button\" tap=\"{{sync}}\" />\n```\n\nLogs:\n\n```\nJS: <<<<<<<<<<<<<< onMapReady >>>>>>>>>>>>>>>\nJS: this._state\nJS: undefined\nJS: <<<<<<<<<<<<<<<<< configure >>>>>>>>>>>>>>>>>\nJS: using default config\nJS: ------------ log:  27132\nJS: -------- count:  0\nJS: ---------- geofences:  0\nJS: [js] location:  {\nJS:   \"activity\": {\nJS:     \"type\": \"unknown\",\nJS:     \"confidence\": 100\nJS:   },\nJS:   \"provider\": {\nJS:     \"network\": true,\nJS:     \"gps\": true,\nJS:     \"enabled\": true\nJS:   },\nJS:   \"odometer\": 0,\nJS:   \"battery\": {\nJS:     \"is_charging\": true,\nJS:     \"level\": 0.6100000143051147\nJS:   },\nJS:   \"event\": \"providerchange\",\nJS:   \"is_moving\": false,\nJS:   \"uuid\": \"b189b3e8-c8da-4a39-a6cb-45323ce9b3e0\",\nJS:   \"coords\": {\nJS:     \"latitude\": 53.8295017,\nJS:     \"longitude\": -1.5489034,\nJS:     \"accuracy\": 20,\nJS:     \"speed\": -1,\nJS:     \"heading\": -1,\nJS:     \"altitude\": -1\nJS:   },\nJS:   \"timestamp\": \"2016-10-28T11:09:11.954Z\"\nJS: }\nJS: [js] location:  {\nJS:   \"activity\": {\nJS:     \"type\": \"unknown\",\nJS:     \"confidence\": 100\nJS:   },\nJS:   \"odometer\": 0,\nJS:   \"battery\": {\nJS:     \"is_charging\": true,\nJS:     \"level\": 0.6100000143051147\nJS:   },\nJS:   \"event\": \"motionchange\",\nJS:   \"is_moving\": false,\nJS:   \"uuid\": \"9bef81e6-9b77-4ac4-8f33-c3a2fba8c604\",\nJS:   \"coords\": {\nJS:     \"latitude\": 53.8295017,\nJS:     \"longitude\": -1.5489034,\nJS:     \"accuracy\": 20,\nJS:     \"speed\": -1,\nJS:     \"heading\": -1,\nJS:     \"altitude\": -1\nJS:   },\nJS:   \"timestamp\": \"2016-10-28T11:09:11.954Z\"\nJS: }\nJS: [js] motionchange false [object Object]\nJS: [js] location:  {\nJS:   \"activity\": {\nJS:     \"type\": \"unknown\",\nJS:     \"confidence\": 100\nJS:   },\nJS:   \"odometer\": 0,\nJS:   \"battery\": {\nJS:     \"is_charging\": true,\nJS:     \"level\": 0.6100000143051147\nJS:   },\nJS:   \"event\": \"motionchange\",\nJS:   \"is_moving\": true,\nJS:   \"uuid\": \"08f4f4df-157a-4354-85e6-89e691272546\",\nJS:   \"coords\": {\nJS:     \"latitude\": 53.8295017,\nJS:     \"longitude\": -1.5489034,\nJS:     \"accuracy\": 14.142000198364258,\nJS:     \"speed\": -1,\nJS:     \"heading\": -1,\nJS:     \"altitude\": -1\nJS:   },\nJS:   \"timestamp\": \"2016-10-28T11:09:13.463Z\"\nJS: }\nJS: [js] motionchange true [object Object]\n10-28 12:09:15.379 24957 25070 W TSLocationManager: ⚠ No JSON found in server response\nJS: [js] http:  {\"status\":200,\"responseText\":\"[{\\\"JourneyID\\\":0,\\\"EventCount\\\":0,\\\"Status\\\":\\\"FAILED\\\",\\\"Message\\\":\\\"TOO_FEW_EVENTS\\\"}]\"}\nJS: Sync successful\nJS: <<<<<<<<<<<<<< onMapReady >>>>>>>>>>>>>>>\nJS: this._state\nJS: undefined\nJS: <<<<<<<<<<<<<<<<< configure >>>>>>>>>>>>>>>>>\nJS: using custom config\nJS: ------------ log:  82231\nJS: -------- count:  0\nJS: ---------- geofences:  0\nJS: [js] location:  {\nJS:   \"activity\": {\nJS:     \"type\": \"unknown\",\nJS:     \"confidence\": 100\nJS:   },\nJS:   \"odometer\": 0,\nJS:   \"battery\": {\nJS:     \"is_charging\": true,\nJS:     \"level\": 0.6100000143051147\nJS:   },\nJS:   \"is_moving\": false,\nJS:   \"uuid\": \"2bf92e9a-90c5-40dc-93aa-f50424563f97\",\nJS:   \"coords\": {\nJS:     \"latitude\": 53.8295226,\nJS:     \"longitude\": -1.5488897,\nJS:     \"accuracy\": 13,\nJS:     \"speed\": 0,\nJS:     \"heading\": -1,\nJS:     \"altitude\": 165\nJS:   },\nJS:   \"timestamp\": \"2016-10-28T11:09:22.000Z\"\nJS: }\nJS: [js] location:  {\nJS:   \"activity\": {\nJS:     \"type\": \"unknown\",\nJS:     \"confidence\": 100\nJS:   },\nJS:   \"odometer\": 0,\nJS:   \"battery\": {\nJS:     \"is_charging\": true,\nJS:     \"level\": 0.6100000143051147\nJS:   },\nJS:   \"is_moving\": false,\nJS:   \"uuid\": \"2bf92e9a-90c5-40dc-93aa-f50424563f97\",\nJS:   \"coords\": {\nJS:     \"latitude\": 53.8295226,\nJS:     \"longitude\": -1.5488897,\nJS:     \"accuracy\": 13,\nJS:     \"speed\": 0,\nJS:     \"heading\": -1,\nJS:     \"altitude\": 165\nJS:   },\nJS:   \"timestamp\": \"2016-10-28T11:09:22.000Z\"\nJS: }\n10-28 12:09:24.879 24957 25073 W TSLocationManager: ⚠ No JSON found in server response\nJS: [js] http:  {\"status\":200,\"responseText\":\"[{\\\"JourneyID\\\":0,\\\"EventCount\\\":0,\\\"Status\\\":\\\"FAILED\\\",\\\"Message\\\":\\\"NO_EVENTS\\\"}]\"}\nJS: [js] http:  {\"status\":200,\"responseText\":\"[{\\\"JourneyID\\\":0,\\\"EventCount\\\":0,\\\"Status\\\":\\\"FAILED\\\",\\\"Message\\\":\\\"NO_EVENTS\\\"}]\"}\nJS: Sync successful\nJS: [js] location:  {\nJS:   \"sample\": true,\nJS:   \"activity\": {\nJS:     \"type\": \"still\",\nJS:     \"confidence\": 100\nJS:   },\nJS:   \"odometer\": 0,\nJS:   \"battery\": {\nJS:     \"is_charging\": true,\nJS:     \"level\": 0.6100000143051147\nJS:   },\nJS:   \"is_moving\": false,\nJS:   \"uuid\": \"2d8ff715-a5dc-4eb7-8da6-ceec70a0d88c\",\nJS:   \"coords\": {\nJS:     \"latitude\": 53.8295158,\nJS:     \"longitude\": -1.5488914,\nJS:     \"accuracy\": 27.2450008392334,\nJS:     \"speed\": -1,\nJS:     \"heading\": -1,\nJS:     \"altitude\": -1\nJS:   },\nJS:   \"timestamp\": \"2016-10-28T11:10:47.845Z\"\nJS: }\nJS: [js] location:  {\nJS:   \"sample\": true,\nJS:   \"activity\": {\nJS:     \"type\": \"still\",\nJS:     \"confidence\": 100\nJS:   },\nJS:   \"odometer\": 0,\nJS:   \"battery\": {\nJS:     \"is_charging\": true,\nJS:     \"level\": 0.6100000143051147\nJS:   },\nJS:   \"is_moving\": false,\nJS:   \"uuid\": \"2d8ff715-a5dc-4eb7-8da6-ceec70a0d88c\",\nJS:   \"coords\": {\nJS:     \"latitude\": 53.8295158,\nJS:     \"longitude\": -1.5488914,\nJS:     \"accuracy\": 27.2450008392334,\nJS:     \"speed\": -1,\nJS:     \"heading\": -1,\nJS:     \"altitude\": -1\nJS:   },\nJS:   \"timestamp\": \"2016-10-28T11:10:47.845Z\"\nJS: }\nJS: [js] location:  {\nJS:   \"activity\": {\nJS:     \"type\": \"still\",\nJS:     \"confidence\": 100\nJS:   },\nJS:   \"odometer\": 0,\nJS:   \"battery\": {\nJS:     \"is_charging\": true,\nJS:     \"level\": 0.6100000143051147\nJS:   },\nJS:   \"event\": \"motionchange\",\nJS:   \"is_moving\": false,\nJS:   \"uuid\": \"09260be2-00ac-4fed-82a1-435862bc6375\",\nJS:   \"coords\": {\nJS:     \"latitude\": 53.8295143,\nJS:     \"longitude\": -1.5488632,\nJS:     \"accuracy\": 24,\nJS:     \"speed\": 0,\nJS:     \"heading\": -1,\nJS:     \"altitude\": 165\nJS:   },\nJS:   \"timestamp\": \"2016-10-28T11:10:49.000Z\"\nJS: }\nJS: [js] location:  {\nJS:   \"activity\": {\nJS:     \"type\": \"still\",\nJS:     \"confidence\": 100\nJS:   },\nJS:   \"odometer\": 0,\nJS:   \"battery\": {\nJS:     \"is_charging\": true,\nJS:     \"level\": 0.6100000143051147\nJS:   },\nJS:   \"event\": \"motionchange\",\nJS:   \"is_moving\": false,\nJS:   \"uuid\": \"09260be2-00ac-4fed-82a1-435862bc6375\",\nJS:   \"coords\": {\nJS:     \"latitude\": 53.8295143,\nJS:     \"longitude\": -1.5488632,\nJS:     \"accuracy\": 24,\nJS:     \"speed\": 0,\nJS:     \"heading\": -1,\nJS:     \"altitude\": 165\nJS:   },\nJS:   \"timestamp\": \"2016-10-28T11:10:49.000Z\"\nJS: }\nJS: [js] motionchange false [object Object]\nJS: [js] motionchange false [object Object]\nJS: [js] heartbeat:  [object Object]\nJS: [js] heartbeat:  [object Object]\n\n```\n\nIt seems everything gets duplicated after resuming the app.\n\nI think this is related to this https://github.com/transistorsoft/nativescript-background-geolocation-lt/issues/27#issuecomment-256665312 and also this https://github.com/transistorsoft/nativescript-background-geolocation-lt/issues/17\n\nI've noticed duplicated journeys in my database that have come from iOS too so this may not be only Android behaving this way.\n"},"comment":{"url":"https://api.github.com/repos/transistorsoft/nativescript-background-geolocation-lt/issues/comments/263917349","html_url":"https://github.com/transistorsoft/nativescript-background-geolocation-lt/issues/28#issuecomment-263917349","issue_url":"https://api.github.com/repos/transistorsoft/nativescript-background-geolocation-lt/issues/28","id":263917349,"user":{"login":"christocracy","id":14999,"avatar_url":"https://avatars.githubusercontent.com/u/14999?v=3","gravatar_id":"","url":"https://api.github.com/users/christocracy","html_url":"https://github.com/christocracy","followers_url":"https://api.github.com/users/christocracy/followers","following_url":"https://api.github.com/users/christocracy/following{/other_user}","gists_url":"https://api.github.com/users/christocracy/gists{/gist_id}","starred_url":"https://api.github.com/users/christocracy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/christocracy/subscriptions","organizations_url":"https://api.github.com/users/christocracy/orgs","repos_url":"https://api.github.com/users/christocracy/repos","events_url":"https://api.github.com/users/christocracy/events{/privacy}","received_events_url":"https://api.github.com/users/christocracy/received_events","type":"User","site_admin":false},"created_at":"2016-11-30T16:18:01Z","updated_at":"2016-11-30T16:18:01Z","body":"get rid of your `setConfig` call within `#stop` callback.  It's unnecessary any to reconfigure `stopOnTerminate: false` when the plugin is already terminated.\r\n\r\nYou're not seeing the *same* http request posted twice.  You're seeing to distinct and valid http requests.\r\n\r\nUnless you can show me locations having identical `uuid` on your server."}}
{"actor":{"display_login":"christocracy"}}