1

i'm follwing @hmscore/react-native-hms-location documontation with react native, i'm trying to Continuously Obtaining the Location Information with the requestLocationUpdatesWithCallback() and addFusedLocationEventListener() functions i can get the request code from requestLocationUpdatesWithCallback() but the addFusedLocationEventListener() returns nothing , like it dosen't trigered

 HMSLocation.FusedLocation.Native.requestLocationUpdatesWithCallbackEx(locationRequest)
  .then((res) => console.log(res))
  .catch((err) => alert(err.message))
  

////////////////////////

HMSLocation.FusedLocation.Events.addFusedLocationEventListener(handleLocationUpdate)


 /////////////////////


const handleLocationUpdate = (locationResult) => console.log(locationResult)

any solution for that

zhangxaochen
  • 32,744
  • 15
  • 77
  • 108
Alaa Mokrani
  • 166
  • 1
  • 11
  • Hello, did you solve your issue? I have same issue, if you solved it can you share how you did it? Many thanks – Vina Nov 24 '21 at 07:52

2 Answers2

1

The location duration depends on the locationRequest configuration.

The parameter settings provided in the Demo do not support continuously obtaining the Location Information. You are advised to configure the parameters as follows:

    const locationRequest = {
      priority: HMSLocation.FusedLocation.Native.PriorityConstants.PRIORITY_HIGH_ACCURACY,
      interval: 60000,    
      numUpdates: 2147483647, 
      fastestInterval: 30000.0,  
      expirationTimeDuration: 2147483647, 
      smallestDisplacement: 0.0,
      language: 'en',
      countryCode: 'en',
    };

For details about the parameters, see Docs.

zhangxaochen
  • 32,744
  • 15
  • 77
  • 108
0

From what it seems, this should work. However, there may be permissions you are missing. Please use requestPermission() and hasPermission() functions to request and check if you do indeed have the necessary permissions to actually receive any location information.

You may also want to make a mock location with setMockMode and setMockLocation to make sure your program is working as expected.

https://developer.huawei.com/consumer/en/doc/development/HMS-Plugin-References-V1/fusedlocation-0000001050043303-V1#EN-US_TOPIC_0000001050140366__section1060819319425

Zinna
  • 1,947
  • 2
  • 5
  • 20