'How to update the user location with Geolocator if the app is in the Foreground?
The app should update the rider's location every second whatever the app is alive or in the foreground, I tried to install the Geolocator and it succeed but whenever the app is in that background or in the Foreground it stops responding.How to solve with that issue.
Some recommend me to work with workmanager !?
Solution 1:[1]
To push location in foreground through foreground service and even when device reboots you can use following library
Solution 2:[2]
try this for getting the the child having max(uniqueId) for a given parent
db.getCollection('your_collection_name').aggregate([
{$sort: {"uniqueID" : 1}},
{$group: {
_id: "$parentID",
children: { $push: "$$ROOT" },
}},
{$match: {_id : {$gt: 0}}}, //exclude results where parentID was 0
{
$project: {_id: 0, "parentID" : 1, "lastChild" : {$last: "$children"}}
},
{$replaceRoot: {"newRoot" : "$lastChild"}}
])
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mudassir Khan |
| Solution 2 | indybee |
