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

HMSLocation.getFusedLocationProviderClient() result in Cannot read properties of undefined (reading 'getFusedLocationProviderClient') issue #120

Open
liuaf opened this issue Jan 15, 2023 · 2 comments

Comments

@liuaf
Copy link

liuaf commented Jan 15, 2023

Description
HMSLocation.getFusedLocationProviderClient() result in Cannot read properties of undefined (reading 'getFusedLocationProviderClient') issue

Expected behavior
HMSLocation.getFusedLocationProviderClient() should return FusedLocationService Object

Current behavior
when I run below codes below result in above issue. Below is the code snippets:

import HMSLocation from "@hmscore/ionic-native-hms-location";

...
const fusedClient = HMSLocation.getFusedLocationProviderClient();
if(fusedClient != null){
fusedClient.getLastLocation({
needAddress : true,
language : "cn",
countryCode : "CN"
}).then((res) =>{
debugger;
console.log(res)
}).catch((err) => {
debugger;
console.log(err)
});
}

Screenshots
HMSLocation issue

Logs
Post logs here or paste them to Ghostbin and insert the link here.

Environment

  • Platform: [Ionic + Capacitor]
  • Kit: [Location, ionic-native-hms-location]
  • Kit Version [e.g. 5.0.3]
  • OS Version [e.g. Android 11]
  • Android Studio version (if applicable) [e.g. 4.1]
  • Platform version (Window10, Huawei Mate40 Pro HarmonyOS 3.0.0)
  • Node Version (if applicable)
  • Your Location/Region (Beijing, China)

Other
Add any other context about the problem here

@TomStroemer
Copy link

TomStroemer commented Feb 28, 2023

I have the same problem. Did you manage to solve it?

I posted it yesterday on stackoverflow and the only comment was - ask it on github. So I found this issue.

What I'm doing:

I'm trying to use HMSLocation to get/subscribe to the location on a Huawei device.

This is an ionic app with android.

I followed the guide here: https://developer.huawei.com/consumer/en/doc/development/HMS-Plugin-Guides-V1/fusedlocation-0000001050142203-V1?ha_source=hms1

  • Added NPM Dependencies: "@hmscore/cordova-plugin-hms-location": "^6.4.0-300" and "@hmscore/ionic-native-hms-location": "^6.4.0-300"
  • Added repo for 'https://developer.huawei.com/repo/' in build.gradle (for buildscript repositories and allprojects repositories)
  • Added classpath 'com.huawei.agconnect:agcp:1.6.1.300' to buildscript dependencies in build.gradle

I'm calling HMSLocation.getFusedLocationProviderClient().... (and so on) and get the error: TypeError: uC.getFusedLocationProviderClient is not a function. I'm testing on a real device, not the emulator. Location is enabled.

I'm using import { HMSLocation } from '@hmscore/ionic-native-hms-location/ngx';

I also found this example: https://github.com/HMS-Core/hms-cordova-plugin/tree/master/cordova-plugin-hms-location/example/ionic
But this does not run - it doesn't even have dependencies to any hms-stuff in its package.json.

@TomStroemer
Copy link

I added this question to the Huawei Developer Forum: https://forums.developer.huawei.com/forumPortal/en/topic/0203112962902561084

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

2 participants