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

Listening beacons in background doesn't work after 1 minute #167

Closed
Kranysys opened this issue Nov 21, 2019 · 10 comments
Closed

Listening beacons in background doesn't work after 1 minute #167

Kranysys opened this issue Nov 21, 2019 · 10 comments

Comments

@Kranysys
Copy link

Version

1.0.1

Platform

Android

OS version

Android 9.0

Expected behavior

Listening the beacons after one minute when the app is in background.

Actual behavior

When the application is in background, it works perfect before 1 minute, then, the library doesn't detect any beacons.
The listener still working like there is no beacon detected.

image

@GiacomoMasi
Copy link

Which version of react native are you using?

@Kranysys
Copy link
Author

Kranysys commented Nov 21, 2019

Which version of react native are you using?

Tested with 0.59.9 and 0.60.4 on different projects, same result.

This may be related to authorization. 1 minute is for Xiaomi Note 7. On another phone I have 2 minutes. We need a solution to keep the listener working in background in long term.

@GiacomoMasi
Copy link

Can you upload the code?

Because I'm using 0.61.4 or 0.60.4 version of RN, and when I call the function startRangingBeaconsInRegion the application closes its self. May be since the version 0.60 something doesn't work in the right way. In the version 0.59 works for me.

@Kranysys
Copy link
Author

Using the example on this repository:

Beacons.detectIBeacons();

// Start detecting all iBeacons in the nearby
try {
  await Beacons.startRangingBeaconsInRegion('REGION1')
  console.log(`Beacons ranging started succesfully!`)
} catch (err) {
  console.log(`Beacons ranging not started, error: ${error}`)
}

// Print a log of the detected iBeacons (1 per second)
subscription = DeviceEventEmitter.addListener('beaconsDidRange', (data) => {
  console.log('Found beacons!', data.beacons)
})

I have the same result with Monitoring a specific beacon UID also.

@GiacomoMasi
Copy link

I tested your code and it works well.
I see in my tests that in RN 0.61.4 the application crashes after the calls of the startRangingBeaconsInRegion function. May be the duration of the scanner depends on the model of the phone

@Kranysys
Copy link
Author

Issue founded, this problem is due to battery saver present on many devices, more informations:
https://dontkillmyapp.com/xiaomi
It works when we disable "Saving Power in The Background".

@sankar9659
Copy link

It's working for me in android but not work in IOS, my react native version is 0.61.5

@Srikanth-Enuguru
Copy link

@Kranysys @sankar9659 @GiacomoMasi Are you able to scan the iBeacons using this library?
If yes could you please share your code or help me in fixing this issue.

@GiacomoMasi
Copy link

GiacomoMasi commented Jul 31, 2023 via email

@akankshaingle
Copy link

I turned off Power Saving mode and now my Android can detect beacons in the background too.

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