-
Notifications
You must be signed in to change notification settings - Fork 223
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
[iOS] Stop working when phone is locked #9
Comments
is this only occurring on-device? I'm testing in the iOS simulator and it continues to work even while locked. |
Also happens for me on Android. |
@tconroy it is on device not working. simulator is working. @Rewieer what android sdk version? i got it working here. |
Here it's Android 5.0. |
Hi, I am having same issue but it stops even iPhone is not locked, if someone have a solution please comment on this: |
It violates the iOS app terms, and it is not possible to run a background task in iOS. |
|
This means... react-native-background-timer will not work in iOS |
@Stoffern Thank you and I already check that link and it really helped me as I lie between one of the category and test going well for now, and for my app I do not even need timer as I had a recursive function that runs automatically based on a reply and wait for at least a minute for second api call. Thanks again for you reply. |
hi anybody solve this? My app suspended after 3 minutes and never execute again. any suggestions please? |
@theonlinenerd that is normal.. read iOS docs... |
It is normal in the sense it is to be expected from the doc point of view. But it is not normal on the programming point of view : he programmed it to keep working on background. I'm not working on IOS, i'm sorry I can't help. |
Ok, here is the iOS docs explained for those who dont want to read them. Definition: Suspended state = clicking the home button and have the app running in the background (not killed) When a app is put into Suspended state a There is exeptions ref: https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html Every of the sections here required a specified iOS function to be called in order to run under the permissions.
|
@Stoffern I am using table 3-1 and using it as fetch now in the focus it is explained it will wake the application to fire whatever written. If this is the case still this timer will not run ? Thank you and will appreciate any help or direction I have to follow. |
It is explained on the page if you read everything under the paragraph that is about the service you use. |
Shouldn't this be in the docs? |
It is in the iOS docs, the repo just claims a feature that does not work in real life. |
In case anyone is interested in a workaround, this seems to work for me:
Note that you should still abide by the apple terms of service, and only do the above if you are in one of their accepted use-cases for background playing. In my case the code inside of the backgorund timer was all related to playing audio so I think I'm okay. |
Hey I used @gshotwell's workaround above and it works great when nobody is using their device. We send location heartbeats to a server to track people's arrival and departure from a job site. Unfortunately, if the user plays audio in other apps on the device it will pause the silent background audio and lead to the app being put to sleep by the OS. Do we have a workaround that works consistently and doesn't require playing a silent audio? This is critical for my app. |
I find all this very hacky solutions, and what i said over a year ago. |
Completely agree - that's why I am trying to find a solution that doesn't use silent audio. Apple clearly states on their developer docs that background location services are an approved function of a background task, and my app in the app store has been approved with background modes - location services enabled. The issue seems to be (at least I suspect) that react native's built in geolocation polyfill does not comply with Apple's guidelines for running a background location task. This in spite of the fact that the react native docs seem to suggest it should work. |
Not working |
@gshotwell your solution worked for me as well. Not only device lock but it also works when app is closed/minimised in iOS. |
Thanks, this fix the issue, I believe because of sound play, OS will not suspend the thread. |
as title says
The text was updated successfully, but these errors were encountered: