-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Geolocation not working #1067
Comments
Try specifying a timeout and see what happens: Geolocation.getCurrentPosition({timeout:15000}).then((resp)..... |
getting error : No luck |
This plugin have a problem. It cannot detect whether gps or location service options are disabled. So, first of all, check if 'Access to my location' option is enabled in your phone. Then activate GPS option, and finally try with your app |
@ihadeed why this issue is being closed without solution |
In my case, my problem was my cell phone was in airplane mode. :/ |
Is there a final fix to this issue. |
The issue is closed because it seems like the error is not with the plugin but with something else, like airplane mode being on, etc. Happy to open it up again if someone can provide more tangible reproduction of a bug in the actual plugin or Ionic Native's wrapper of it. |
Not working for me on iOS device. Always get an error. After installing the plugin, no specification is made in Info.plist of the app requesting to use location. Maybe the error is there... |
@mlynch Please reopen: by ruling out all other potential issues, my testing seems to indicate that Ionic is the source of this bug. I can share more detailed results if requested. My conclusion: WebView is not the issue, no problems with native SDK or airplane mode. Geolocation works fine in stand-alone Cordova, and it also works when using a specialized Cordova GPS plugin. Note: Using airplane mode does not disable Geolocation except when using a non-cellular enabled, WiFi-only tablets. Using airplane mode will actually force Geolocation to use GPS on all cellular-enabled devices. Cross-reference: andygup/ionic2-esri-map#8 |
Here's a project using |
@ihadeed Thanks for clarifying and providing the sample, yes the Ionic Geolocation plugin pattern in that repo does work for me. Verified on Ionic 3.18.0/Cordova 7.1.0 compiled with Android 6.3.0 running on an Nexus 6P at Android 8.0.0. However there was another issue we noted. We have customers initializing Problem: This pattern broke at Angular 5: ngOnInit(){
// This pattern is now broken! :-(
navigator.geolocation.watchPosition( . . . );
} Resolution: We have been able to resolve this lifecycle issue by making sure to use Ionic's Here's a psuedo-example: async startLocation(){
await this.platform.ready();
navigator.geolocation.getCurrentPosition(function(result){ . . . }
}
ngOnInit(){
. . .
this.startLocation();
. . .
} STATUS: Resolved |
i think this happened because of timing problem if anyone have timing problem maybe try this its perfectly working ` ngOnInit(){ MyLocation(){ |
Leaving this link here in case it helps others test Geolocation on Android: https://blog.ionicframework.com/testing-geolocation-on-android/ |
Even if I provide timeout neither then nor catch works |
I am having the same issue. Is there any updated solution for this? |
what is the issue ?
…On Thu, Jan 11, 2018 at 11:46 AM, Muhammad Rafay Farooq < ***@***.***> wrote:
I am having the same issue. Is there any updated solution for this?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1067 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AbLYxAtEOupJvqDSgiYeYva0QnysSkExks5tJYP4gaJpZM4L_YrQ>
.
|
The code is neither going to then block nor catch any error and just exit. Tried the repo of ihadeed and also the example is given by you and same result. Your example is throwing a timeout. Trying on emulator and running ihadeed repo. |
let options = {
timeout: 30000,
enableHighAccuracy: true
}
this.geolocation.getCurrentPosition(options).then((data) => {
// do something here
this.loadMap(lat,lng);
});
this code is working perfectly now.
…On Fri, Jan 12, 2018 at 10:36 AM, Muhammad Rafay Farooq < ***@***.***> wrote:
The code is neither going to then block nor catch any error and just exit.
Tried the repo of ihadeed and also the example is given by you and same
result. Your example is throwing a timeout. Trying on emulator and running
ihadeed repo.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1067 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AbLYxLCg0nr8NW8D_SuNlvEwDKjdqNqcks5tJsVCgaJpZM4L_YrQ>
.
|
I think timeout:30000 make it work. Previously it was not working when set to 10000. |
Hello guys, well...nothing is working for me... I tried the codes here...but keep returning Error or empty values. I turn on my gps, enable permissions...I tried to run on emulator...but still not working...I cloned the project from @ihadeed but didn't work. Tested on Xperia X Compact(7.1.1) and Samsung S5 (6.0) global packages:
local packages:
System:
Any ideas?? |
Same here.. The geolocation plugin is not working in Android O. Can anyone help me on this? |
What i did is perfectly working
…On Feb 7, 2018 4:54 PM, "jeffreyrajanofficial" ***@***.***> wrote:
Same here.. The geolocation plugin is not working in Android O
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1067 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AbLYxPPE3IZyFu_TRwpNxy1fuIglZTXtks5tSWS7gaJpZM4L_YrQ>
.
|
I am having the same issue using a Nexus 7 with Aeroplane mode enabled. The code below does not log anything to the console, and does not timeout. this.geolocation.getCurrentPosition({timeout: 30000}).then((resp) => {
console.log(resp);
}, (error) => {
console.log(error);
}).catch((err) => {
console.log(err);
}); |
Guys, I tried to compile in another computer...and believe...it works! But only with the GPS turn on. I didn't change the code of @ihadeed. Just compile...See my infos here...it's a downgrade... ionic/cli-utils : 1.19.0 global packages:
local packages:
System:
I believe it's something about the SDK version or Gradle... The gradle here is 4.1. |
I had difference solution, more of a general understanding of Geo Location. I wrote about it because I figured it out after a lot of struggle and research. Hope it helps. |
Hi, I have followed the link bellow to test on the device: Checking on Android Studio Logcat I see: My AndroidManifest.xml is:
What other permission should be there? |
@ihadeed - clonned your project, not working in android. |
I'm having similar issues. I've been debugging it for a while now and it's related to the fact that the application is running locally on the HTTP protocol instead of HTTPS. https://developers.google.com/web/updates/2016/04/geolocation-on-secure-contexts-only When deployed directly to the device it works just fine. When using emulators without the live and console flags, it works fine as well. |
I've the same problem, but... something's geolocation is working on Android.... When i try with the example is the same, something's not working and something's working. (i'm not in airplane mode). (if i open Gmaps or other, GPS work fine, is not my phone the problem). This problem is only on Android, with iOS and browser work perfectly |
Try Background Geolocation instead of Geolocation it solved my problem |
There is just something wrong somewhere with android and getting location.. My geolocation code works well with 'ionic serve'. But just getting error callback (timeout error) on android. I increased the timeout to 30 seconds, still the same error... Probably it has to do with versions. |
Hi all. This is a bug in Cordova. The Geolocation implementation for Android relies on the web view geolocation implementation, but that behavior with Android is broken. The only solution here is for Cordova to add back the native geolocation implementation. We have a discussion going internally about how we might do that, but it also seems that Cordova is not interested in bringing that code back. However, Capacitor, our new native bridge to replace Cordova, does use the native implementation. Once Capacitor is integrated into Ionic Native, this issue will be resolved. Until then, this plugin will also have that bug. Closing until we have more information. |
Its not going in .then nor in .catch for android.
Working fine in browser.
Was working fine in previous ionic versions.
Geolocation.getCurrentPosition().then((resp) => { console.log("position", resp) }).catch((error) => { console.log('Error getting location', error); });
config.xml -
<plugin name="cordova-plugin-geolocation" spec="~2.4.1" />
package.json
"ionic-native": "^2.2.11",
system information:
Cordova CLI: 6.5.0
Ionic Framework Version: 2.0.1
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.1.0
ios-deploy version: 1.9.0
ios-sim version: 5.0.11
OS: macOS Sierra
Node Version: v7.4.0
Xcode version: Xcode 8.2.1 Build version 8C1002
Android device version 6.0.1
Note: permission is granted to app
The text was updated successfully, but these errors were encountered: