Ionic-native: Geolocation not working on MIUI 8 (Xiaomi mi5s)

Created on 19 Jun 2017  Â·  26Comments  Â·  Source: ionic-team/ionic-native

I'm submitting a ... (check one with "x")
[x ] bug report
[ ] feature request

Current behavior:
When I try to get my current position, the device just takes a really long time (2-3 minutes) to get it, while Google Maps itself works pretty nice. Works great on a Samsung S5, but... why not in my Xiaomi device?

Expected behavior:
Should get the current position really quick, as it does with other apps.

Steps to reproduce:
It stops for so long time, at this particular line:

this.geolocation.getCurrentPosition().then((position) => {
-->

Related code:

insert any relevant code here
Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):

global packages:

@ionic/cli-utils : 1.4.0
Cordova CLI      : 7.0.0
Ionic CLI        : 3.4.0

local packages:

@ionic/app-scripts              : 1.3.1
@ionic/cli-plugin-cordova       : 1.4.0
@ionic/cli-plugin-ionic-angular : 1.3.1
Cordova Platforms               : android 6.2.3
Ionic Framework                 : ionic-angular 3.0.1

System:

Node       : v7.9.0
OS         : Windows 10
Xcode      : not installed
ios-deploy : not installed
ios-sim    : not installed
npm        : 4.2.0

package.json:

{
"name": "Myapp",
"version": "0.0.1",
"author": "Ionic Framework",
"homepage": "http://ionicframework.com/",
"private": true,
"scripts": {
"clean": "ionic-app-scripts clean",
"build": "ionic-app-scripts build",
"ionic:build": "ionic-app-scripts build",
"ionic:serve": "ionic-app-scripts serve"
},
"dependencies": {
"@angular/common": "4.0.0",
"@angular/compiler": "4.0.0",
"@angular/compiler-cli": "4.0.0",
"@angular/core": "4.0.0",
"@angular/forms": "4.0.0",
"@angular/http": "4.0.0",
"@angular/platform-browser": "4.0.0",
"@angular/platform-browser-dynamic": "4.0.0",
"@ionic-native/core": "^3.6.0",
"@ionic-native/geolocation": "^3.8.0",
"@ionic-native/splash-screen": "^3.5.0",
"@ionic-native/status-bar": "3.4.2",
"@ionic/storage": "2.0.1",
"cordova-android": "^6.2.3",
"cordova-plugin-compat": "^1.0.0",
"cordova-plugin-console": "^1.0.5",
"cordova-plugin-device": "^1.1.4",
"cordova-plugin-geolocation": "^2.4.3",
"cordova-plugin-googlemaps": "~1.4.0",
"cordova-plugin-splashscreen": "^4.0.3",
"cordova-plugin-statusbar": "^2.2.1",
"cordova-plugin-whitelist": "^1.3.1",
"image-manipulation": "0.0.4",
"ionic-angular": "3.0.1",
"ionic-plugin-keyboard": "^2.2.1",
"ionicons": "3.0.0",
"parse": "^1.9.2",
"rxjs": "5.1.1",
"sw-toolbox": "3.4.0",
"zone.js": "^0.8.4"
},
"devDependencies": {
"@ionic/app-scripts": "^1.3.1",
"@ionic/cli-plugin-cordova": "1.4.0",
"@ionic/cli-plugin-ionic-angular": "1.3.1",
"typescript": "~2.2.1"
},
"description": "An Ionic project",
"cordova": {
"plugins": {
"cordova-plugin-whitelist": {},
"cordova-plugin-geolocation": {},
"cordova-plugin-console": {},
"cordova-plugin-device": {},
"cordova-plugin-googlemaps": {
"API_KEY_FOR_ANDROID": "AIzaSyDFX_9vIksX3JMDVjDIRa5bxoioWCW_q4g",
"API_KEY_FOR_IOS": "AIzaSyDFX_9vIksX3JMDVjDIRa5bxoioWCW_q4g"
},
"cordova-plugin-splashscreen": {},
"cordova-plugin-statusbar": {},
"ionic-plugin-keyboard": {}
},
"platforms": [
"android"
]
}
}

Most helpful comment

I expected it to be rectified on MiUI9 but it was not. So I eventually decided to look for other plugins. And google maps plugin did a much better job. It was faster and offered google play services . But its heavy. I needed maps too so I decided to go with it.

All 26 comments

I must add that I'm not completely sure if the problem is with MIUI 8 or with Android 6...

Update your dependencies to theirs latest releases and try it again.

@danielsogl What do you recommend me for that? Should I run npm install in my project folder? I think they are in their latest releases, but I don't really know

Updated @ionic-native/geolocation to the version 3.12.1, works the same in navigator, but still having the same problem in my Xiaomi.

Any ideas?

Check out the latest ionic release notes for release 4.3.x.
Then,run npm outdated to see the latest available releases.

The latest release for ionic native packages are 3.12.x

Used npm update, then npm install. Now my whole project is dead and ionic serve won't work. I'm trying to fix this up and then try to get back into upgrading the depedencies individually, but now, I'm in a dead point. Will update as soon as I get the project fixed.

NPM should get its shit together with the dependencies management...

@danielsogl Updating the dependencies didn't work. Now my project is properly migrated to the latest version of each peer dependency, and everything works fine, except for the geolocation thingy.

I tried many things, I'm even monitoring the device and could locate the problem: both cordova navigator geolocation plugin, and ionic-native/Geolocation, fail delivering a response. They just throw error 3 always: timeout, and after some time, they reply with the position. Is taking usually 3-4 mins for that reply.

At the moment, it only happens to my Xiaomi mi5s (MIUI 8, Android 6), but it may happen in other devices. Tried everything, even disabling the high precission, but I can't still get a good location, though other apps do it correctly (tried with JustEat and Google Maps). Do you know what may be happening?

PD: It works perfectly in a Samsung S5 and the browser.

Thank you!

@Zerokk
it is known that some Xiaomi devices with specific ROMs (EU MIUI ROM i think) have a problem with geolocation service. It's software problem. You can find some discussions here (https://xiaomi.eu/community/)
I tested my app on multiple Xiaomi devices (Redmi 3, Redmi Note 3 PRO, Mi5sPlus), all with MIUI 8 on global ROM and geolocation service works without problems

Looks like an issue with the plugin, and not with the Ionic Native wrapper. I'm going to close this issue but feel free to keep the conversation going.

To verify that it's not an Ionic Native issue, please run the following command and compare the behaviour with the one you experienced earlier:

import { Geolocation } from '@ionic-native/geolocation';

...

// run this somewhere in your code
Geolocation.getPlugin().getCurrentPosition(x => console.log('Success', x), e => console.log('Error', e));

@ihadeed I don't get any response from that snippet. It's just as with the normal one: it just gets a lot of time to get a response from the GPS.

@stormwin I can't find any thread that talks about it; I'm thinking in posting the bug by myself. Do you know if there's a discussion about this topic? They should release an update if it's a ROM problem. Anyways, geolocation works good for you? Don't you know if there can be any workaround to fix this?

I'm beginning to think that Cordova is not suitable for proper GPS functioning, as many people say... I don't feel any comfortable knowing that my app doesn't work in 1 out of 2 devices I tried this far.

I am facing the same issue with my Redmi Note 4. Did you find any solution to the problem?

Actually not, it seems to be a widespread problem...

El 5 oct. 2017 12:45 p. m., "Karan Sharma" notifications@github.com
escribió:

I am facing the same issue with my Redmi Note 4. Did you find any solution
to the problem?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/ionic-team/ionic-native/issues/1703#issuecomment-334428774,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AKM8EQrUwddxwr6Dg5WBGsIe-c6SgQZqks5spLMzgaJpZM4N-InX
.

So what can be done? Actually it worked fine in my Redmi some days back. IDK what happened now. Any workaround??

None. I just could not fix this and in fact, it posed a problem to my app,
and I'm still waiting Xiaomi and/or Cordova to put a fix. This should be
more observed by the Ionic team and help putting pressure so this gets
fixed for everyone.

El 5 oct. 2017 12:53 p. m., "Karan Sharma" notifications@github.com
escribió:

So what can be done? Actually it worked fine in my Redmi some days back.
IDK what happened now. Any workaround??

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/ionic-team/ionic-native/issues/1703#issuecomment-334430474,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AKM8Ef3Ny8YVmbf7tZVjl5Vrnv6H4ML2ks5spLUQgaJpZM4N-InX
.

I am having the same issue with note 4. I had it earlier but an MIUI update fixed it. But the latest update broke it again. Its not a problem with ionic wrapper so its not going to be solved here.

I am having the same issue with Redmi Note 4.

It is a cordova plugin issue. But I dont think its going to be fixed from their side. Background geolocation plugin do work. But the plugin 5 times heavier .

I am also facing same issue in redmi MIUI 8. but working fine woth redmi note 3. but not working in redmi 4 and note 4.

I expected it to be rectified on MiUI9 but it was not. So I eventually decided to look for other plugins. And google maps plugin did a much better job. It was faster and offered google play services . But its heavy. I needed maps too so I decided to go with it.

@Zerokk, Your package.json exposes your API Keys, hope you've changed them by now.

Please help,
it tested on different Android phones to identify current location issues, find below results :

Mobile Handset | Android Version | Status (current location shows)

Moto G4 Plus | Android 7.0 | WORKING
MI Note 3 | Android 6+, MIUI 8+ | WORKING
Honor holly 2 plus |   | WORKING
Coolpad 3600I | Android 6.0.1 | NOT WORKING
Samsung J7 |   | WORKING
Moto g 3 |   | WORKING
Moto g 3 | Android 6 | NOT WORKING
Redmi note 4 | Android 7, MIUI 9 | NOT WORKING
Redmi 4 | Android 7.1.2 MIUI 9.1 | WORKING

@rajeevriitm I am curious about you mentioning that the google maps plugin using the getMyLocation() is performing better. Did you have any problems using that? Can I just use that function and not any of ther other google maps functions which I don't need?

@dmastag I am yet to face any problem . I did make a pull request to use getMyLocation to work without loading map. But I havent tested on many phones. Would be happy to see it tested on many phones. You can check the latest commit but I dont think documentation is ready yet.

@Spanchal21 I think it might be a MIUI issue?
My location services used to work when i was on MIUI 8.X
Failed to work after I upgraded it to 9.1

Same app works on a samsung galaxy 5.

I am having the same issue too with Redmi Note 4, Android 7, MIUI 9. Android Emulator with Nexus 5 is also returning nothing. I have all the dependencies updated.

With Moto G4 Plus, ionic serve and iOS it is working fine. I will test it on other devices soon.

test on Redmi note 4 | Android 7
turn on gps device only not with assistant by wifi or cellular network it's fix my ionic app with geolocation.

Was this page helpful?
0 / 5 - 0 ratings