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

[Android] Turning GPS on while app is running does not work? #54

Closed
SylvainBigonneau opened this issue Mar 24, 2015 · 7 comments
Closed

Comments

@SylvainBigonneau
Copy link

I do no know if it is in the scope of this project, but when I start up, say, simple-map on my Android phone with the GPS turned off, and only then turn the GPS on while the app is running, meteor is unable to catch that activation. (also, the geolocation icon does not appear in the status bar, unless I am using another geolocation app in the background)

Only if I press the back button does it "reload" the app and then it works, and the geolocation icon appears. It also works if I have GPS turned on prior to launching the app.

Is there a way to detect GPS activation within the meteor app? Or should I put a "check again" button on my app that does ̀window.location.reload()` ?

@caio-ribeiro-pereira
Copy link
Contributor

Hi, I helped solve this issue, sending this PR (df1b174).
Please, update this package for version 1.0.3, and to solve your problem, you just need to run this code below to check if the GPS is turned on:

Template.gps.helpers({
    hasGPS: function() {
        return !!Geolocation.error();
    }
});

and in your template use this snippet:

<template name="gps">
    {{#if hasGPS}}
         <h1>GPS online!</h1>
    {{else}}
        <h1>GPS offline, turn the gps on and <a href="#" onclick="window.location.reload();">reload the app</a>.</h1>
    {{/if}}
</template>

Now there is a timeout of 10 seconds checking if the GPS is on, if not it throws error.

This code runs on mobile too. I hope this code can help you!

@SylvainBigonneau
Copy link
Author

Thanks a lot! That solves the detection problem! Now we only need to find a way to not ask the user for a manual reload, as any production app would not.

@caio-ribeiro-pereira
Copy link
Contributor

I didn't find a way to create a button for turn on gps, but if you find
please share with us!

Att,
Caio Ribeiro Pereira
Software Engineer
http://crpwebdev.com
On May 21, 2015 3:18 AM, "BraveKenny" notifications@github.com wrote:

Thanks a lot! That solves the detection problem! Now we only need to find
a way to not ask the user for a manual reload, as any production app
would not.


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

@vinaypuppal
Copy link

Hope this might be helpful to who reach here with this GPS problem. Plugin for phonegap/cordova to display a dialog and redirect to GPS settings when the GPS is disable. https://github.com/rodrigo-martinezd/cordova-dialog-gps

@dhavalrajani92
Copy link

Hello @vinaypuppal have you used with meteor? if yes than give me tarball url for installation or any example

@vinaypuppal
Copy link

@dhavalrajani92 Yes I have used it working perfectly, here is the tarball url https://github.com/rodrigo-martinezd/cordova-dialog-gps.git#f1103143fcf725fb98be8af7cbf98383945225ab

@StorytellerCZ
Copy link
Collaborator

I'm closing this issue as it has been fixed.

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

5 participants