Closed peterbodo closed 3 weeks ago
I don’t see that you’re calling .ready(config)
Since the docs says that ready can be called once and only once, I call it from a useeffect at first render. Since we have several sessions with changing config we use only setConfig each time.
const initBG = async () => {
const accessToken = await getFromStore("accessToken");
const userId = await getFromStore("userId");
const sessionId = "init";
const options = getBackgroundGeolocationOptions(
sessionId,
userId,
accessToken
);
await BackgroundGeolocation.ready(options);
};
useEffect(() => {
initBG();
return () => {
if (onLocation) onLocation.remove();
};
}, []);
See wiki “Debugging”. Configure the plug-in for verbose logging, enable debug: true, launch your app in XCode and observe the logs of your app launching.
I don't own a mac :)
BTW the code continues to run perfectly in android. And in ios if I kill the app and relaunch (now, with previously given permissions) the tracking starts as expected.
It looks like that during permission requests in iOs the app is somehow losig track where it paused to run code.
I don't own a mac :)
How do you expect to efficiently develop a cross-platform app without the ability to debug locally?
Create for me a simple “hello-world” app which reproduces the problem and share it in a public GitHub repo so I can try it myself.
okay, thanks for the offer, but went biking and realised that the demo app would be an overkill (at least to produce by me), So I rather channeled error messages to the server.
Now, what I see is that immediately as the permission dialogues appear an error:1 happens. This tells me that onlocation is already triggered and the error is of course location permission denied since ther was not yet a chance to select a permission.
With the exact same app on android, there is no error. there is no onlocation event until all the permissions are selected.
what worries me is that if I understand well it is #start, which handles both permissions and starting to get locations as well, so there is no way that I listen to an event of permission changes and start getting locations manually.
(In Android even the activity indicator stops circling, whil I select permissions. On the other hand on iOs it keeps making circles.)
I don’t understand your problem.
show me logs.
see api docs “Logger” and learn to use the .emailLog method.
ok I will, but the problem is that onlocation starts firing on ios as soon as permission dialogues come up, and since no permission was given yet, it throws a locationerror:1
Have you read the api docs for onLocation?
If you were watching the logs and not scurrying about blindly developing an iOS app without a Mac, you’d see a warning in the logs about not providing the optional 2nd argument locationErrorCallback
to onLocation
.
Also my code is in a try/catch block. I just realised that my main problem is that after the locationerror the other code part stops executing.
Nevertheless the root cause is onLocation firing too early.
In the meantime I have read your comment. Okay this will be the way to go
still don't understand why onlocation is firing, but anyway. catching an error was never a problem.
still don't understand why onlocation is firing, but anyway. catching an error was never a problem.
Because you didn’t provide the 2nd argument to onLocation, the plug-in has no other option to inform you an error occurred but to send it to the only callback you did provide to onLocation.
Read the api docs onLocation
Have you read the api docs for onLocation?
I think maybe sometime :) And really grateful for the excellently documented project, but if we are realistic it is impossible to read (and especially learn) all the docs of all the libs we use.
If you were watching the logs and not scurrying about blindly developing an iOS app without a Mac, you’d see a warning in the logs about not providing the optional 2nd argument
locationErrorCallback
toonLocation
.
Poor developer cooks with water :)
But anyway. Thanks a million. That will be the solution.
I just wanted to share with you that the locationerrorcallback has solved the problem. And also do not put those in a try catch.
Thanks a lot for your help.
And still I think it is worthwile investigating that android hangs up until permissions are dealt with, but iOs not.
And still I think it is worthwile investigating that android hangs up until permissions are dealt with, but iOs not.
These are completely different operating systems. I have no control over how the OS handles their permission dialogs.
Your Environment
react-native -v
): 0.72.5Expected Behavior
Permission requests pause code, after requests given code continues.
Actual Behavior
at #start permissions are asked. code after start never runs code runs on Android!
Steps to Reproduce