Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with background geolocation #3

Open
jeangui opened this issue Mar 14, 2015 · 21 comments
Open

Error with background geolocation #3

jeangui opened this issue Mar 14, 2015 · 21 comments

Comments

@jeangui
Copy link

jeangui commented Mar 14, 2015

Hello,

I have tried the package example (deployment : http://jgl-meteorbggeo.meteor.com).
It does work correctly with the Foreground feature in web & mobile context (I had to change the code for the mobile case).
But I get error when I launch the background thread as depicted in the following screenshot:

https://drive.google.com/file/d/0B1H-jx3teB5-TklOOUp0cDRTQVZDTTNLU1lFbmc4dzN1UE9j/view?usp=sharing

The last 2 geolocations are the ones coming after the background thread launch.

As you can see, the first one does not have any location. It is just a simple json object with only an id.
The second one has latitude, longitude, userid and uuid but there is no location parameter.

What should I modify to make it work. A meteor after insert hook ?

Thanks in advance for the help.

Regards,

@jeangui
Copy link
Author

jeangui commented Mar 19, 2015

Any idea ?

@hems
Copy link

hems commented Mar 30, 2015

@jeangui i believe the best idea would be to fix this before inserting into the collection..

i'll have a look on the code and see if i can figure out a solution

@jeangui
Copy link
Author

jeangui commented Mar 31, 2015

Hello,

I have not any time to test it but in my mind the best way will be to use the matb33/meteor-collection-hook package with the function .before.insert.
Moreover it will be nice to have a flag on the object sent to the server with the context (FG, BG, android, ios, ...). By this way it will easier to do the transformation on the fly before inserting.

Cheers
@jeangui

@zeroasterisk
Copy link
Owner

I agree, hooks are really nice.

I just want to provide an easy and somewhat consistent solution, if this is a common problem. Perhaps an optional extra package to setup the hook for you, or at the very least, an example of the solution.

@jeangui
Copy link
Author

jeangui commented Apr 8, 2015

Hello @zeroasterisk ,

Have you got a better solution finally ?

cheers
@jeangui

@zeroasterisk
Copy link
Owner

I don't clearly understand the problem. Please explain with detail and I'll
see what I can come up with.
On Wed, Apr 8, 2015 at 3:07 AM jeangui [email protected] wrote:

Hello @zeroasterisk https://github.com/zeroasterisk ,

Have you got a better solution finally ?

cheers

@jeangui https://github.com/jeangui


Reply to this email directly or view it on GitHub
#3 (comment)
.

@jeangui
Copy link
Author

jeangui commented Apr 9, 2015

Hello Alan,

Thanks a lot for your help.
I have several problem finally. So maybe this is not the best place to discuss about it here.

Here are the subject I am dealing with:

  1. The uuid, device information are not set when coming from the background thread.
  2. The background thread seems not to work well on IOS. That is strange because I used to test on my iphone and on the IOS simulator the initial cordova christocracy package and it works perfectly. I only get a location sending when either I click on "getBackground" or either when I suspend the application. I don't get any update otherwise even when I walk/run in the street with my iphone or either when I test with the IOS Simulator and the location simulator service.

Here is the difference in the GeoLog inserted object in terms of structure and information:

https://s3-eu-west-1.amazonaws.com/screenshotsbugs/Capture+d%E2%80%99e%CC%81cran+2015-04-09+a%CC%80+13.37.26.png

Here is the code I used in terms of configuration:

https://s3-eu-west-1.amazonaws.com/screenshotsbugs/Capture+d%E2%80%99e%CC%81cran+2015-04-09+a%CC%80+14.44.57.png

Here is the code that I commented in order to avoid background stopping by error:

https://s3-eu-west-1.amazonaws.com/screenshotsbugs/Capture+d%E2%80%99e%CC%81cran+2015-04-09+a%CC%80+14.58.53.png

Maybe it is related to the function changePace() which is used in the christocracy package sample and not in your meteor package.

Have you already tested with IOS device ?

Thanks again for your help.

jeangui

@zeroasterisk
Copy link
Owner

Thanks for the information.

I honestly haven't looked at it in a little while. I may be dusting it off sometime in the near-ish future, but unfortunately it's not easy to setup and play with. I know at one point it was working as expected with both Android and iOS devices, foreground and background.

Maybe, make sure the setup() function isn't called until we have valid information on the device... like maybe not even on Meteor.startup() but check in the client that you can get to the UUID, and then run setup()?

For iOS (non-android), I believe the send() callback is maybe where we are "stripping off" the extra details like speed, and accuracy. Instead of this, we should simply be adding on to the object, not stripping off of it.

Possible issues:

  • the setup() callback should come with some easy way to defer until there's a valid UUID of the device.
  • the send() callback should be sending the userId, uuid, device options configured in setup vs trying to look them up, while in the background
  • the send() callback should be extending location as the data, not only plucking off the lat/ln.

@jeangui does that all make sense? sound like, related to the things you're dealing with?

any chance you want to make your own fork and play with it and see if you can improve it?

if not, I will get to it, but it will likely not be for a few weeks.

@jeangui
Copy link
Author

jeangui commented Apr 9, 2015

@zeroasterisk

Thanks for all those good tips. :)
I gonna try to defer the setup function.
Maybe It would be better to do a fork in order to start from a new basis.
Especially I have a question concerning your choice of using the romainstrock cordova plugin instead of the christocracy one directly. Is there a special reason ?

I'll keep you informed of my findings.

Cheers
Jeangui

zeroasterisk added a commit to zeroasterisk/meteor-cordova-geolocation-background that referenced this issue Apr 10, 2015
- [x] send() callback now uses full location object
- [x] send() callback now uses this.options.params for userId/uuid/device
      (if setup) -- because if being called in the background,
      it probably can't get them then (duh)
- [x] setup() not wrapping params setup in a Tracker.autorun()
      (no idea if this will work on not, needs to be tested... @jeangui)
- [ ] test these changes on iOS
- [ ] test these changes on Android

refs zeroasterisk/meteor-cordova-geolocation-example#3
@zeroasterisk
Copy link
Owner

@jeangui I have put up a commit on a develop branch, which might address these issues --- totally untested... wanna give it a shot?

zeroasterisk/meteor-cordova-geolocation-background@b04be8e

you should be able to try it out with something like:

cd yourapp
mkdir packages
cd packages
git clone https://github.com/zeroasterisk/meteor-cordova-geolocation-background "zeroasterisk:cordova-geolocation-background"
cd "zeroasterisk:cordova-geolocation-background"
git checkout develop
git pull origin develop
cd ../..
meteor

when you're done, you can always rm -rf packages/zeroasterisk:cordova-geolocation-background

@jeangui
Copy link
Author

jeangui commented Apr 10, 2015

@zeroasterisk Fine ! Thanks a lot for the help. I gonna give a try today.
I'll tell you the result of my testing. I don't have any android device unfortunately.

jeangui

@jeangui
Copy link
Author

jeangui commented Apr 13, 2015

Hi @zeroasterisk

I did quickly a try yesterday but it does not work.
You can see the result here : http://jgl-meteorbggeo.meteor.com/
There are some bugs that I have already corrected (the OPTION HTTP request should not induce an insert in the geolog collection for instance).
I gonna try to change some code this week if I get some time to do so.

Cheers
jeangui

@hems
Copy link

hems commented Apr 20, 2015

@jeangui hey thanks for having a look at this!

let me know if you need help with testing / code

@jeangui
Copy link
Author

jeangui commented Apr 23, 2015

Hello,

I haven't found any time to work on it up to now. I gonna try next week. I think I will start from the cristocracy demo app first and then migrate it to meteor before creating a meteor package.

May our problem be related to configuration ? mobile-config.js ? Just an idea...

I'll keep you informed.

cheers
Jeangui

@hems
Copy link

hems commented Jun 3, 2015

@jeangui i'm back into this recently, so far only using the standard Geolocation package, which stops reporting when the user locks the phone.

i'll keep an eye here, so hopefully i can help somehow

@jeangui
Copy link
Author

jeangui commented Jun 5, 2015

Hello @hems,
Finally I haven't got so much time to look at it.
Thanks to your post, I tried to get further but I am blocked on the following problem:

https://forums.meteor.com/t/package-creation-issue/5333

I hope I will get something working soon.

Best regards

@hems
Copy link

hems commented Jun 6, 2015

I tested this package using the cordova example he has: https://github.com/christocracy/cordova-plugin-background-geolocation and it worked perfectly for me on iPhone 5..

does that help?

@jeangui
Copy link
Author

jeangui commented Jun 7, 2015

Hello henrique,

Thanks for your feedback.

This is strange.

Why it does not work for me. I have may done something wrong when testing.

What is your configuration ?

cordova ? meteor ? xcode ?

So you get the location coordinates on the web site (through the rest api)
even when using the background mode ?

I gonna give a new test tomorrow.

Best regards,

jeangui

2015-06-06 18:46 GMT+02:00 henrique matias [email protected]:

I tested this package using the cordova example he has:
https://github.com/christocracy/cordova-plugin-background-geolocation and
it worked perfectly for me on iPhone 5..

does that help?


Reply to this email directly or view it on GitHub
#3 (comment)
.

@hems
Copy link

hems commented Jun 15, 2015

@jeangui i mean this repository?

i just followed readme instructions:

cd example/SampleApp
$ cordova plugin add https://github.com/christocracy/cordova-plugin-background-geolocation.git
$ cordova platform add ios
$ cordova build ios

@jeangui
Copy link
Author

jeangui commented Jun 15, 2015

Hello @hems

Ok I didn't understand you were talking about this repository.
I didn't know that Christocracy did create a meteor package.
I gonna test it.

thanks.
jeangui

@jeangui
Copy link
Author

jeangui commented Jun 15, 2015

Oups. Sorry. I misunderstood again.
yes I did know the cordova plugin that Christocracy built up.
I did already test the SampleApp with cordova only. And it works perfectly for me as well.

What I want is to make the thing works in a meteor sample.
@zeroasterisk did a package for achieving this. But it does not work well for me. Maybe I am doing things not in the correct way (in addition, since IOS 8.3 the behavior is even worse).

But I didn't know about christocracy meteor package. 25 days old.
It help me about my package version number. It is fine now when I add the cordova package in meteor.
I don't have so much time but I am trying to make the @zeroasterisk works with christocracy new meteor package. Right now I have still errors.

regards,

jeangui

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants