Task defined did not run in IOS
I used the Simple example provided in your readme and I can't see the msg logged in the Chrome React Native Debugger. Not sure what I missed.
Packages Versions:
- Xcode: 8.2.1
- NPM: 3.10.10 "react": "16.0.0-alpha.12", "react-native": "0.45.1", "react-native-background-fetch": "^2.0.8", "react-native-background-task": "^0.2.0"
Try using the "Simulate Background Fetch" feature of Xcode, documented here: https://developer.apple.com/library/content/documentation/IDEs/Conceptual/iOS_Simulator_Guide/TestingontheiOSSimulator/TestingontheiOSSimulator.html#//apple_ref/doc/uid/TP40012848-CH4-SW5
Were you using a simulator or device? From what I understand the Simulator doesn't run background code by itself. If you were using a real device then it probably should have run after ~15 mins.
It was tested on device.
Can you try out with Simulate Background Fetch and just confirm that works first?
If it does, it's probably a sign that the task is set up properly, but Apple's algorithm is choosing not to run it (which sadly there isn't much we can do about).
Did you force close the app, rather than just leaving it running in the background? That's one which will unfortunately stop the background task occurring (until the user opens the app again), under Apple's policies.
The app was not closed. Home button is pressed to leave the App in Bg. I tried out the Simulate Bg Fetch in Simulator and it didn't work either. I think it may be easier if you can include a repo of working example which I can clone to have a look, since you already tested and confirmed that it is working?
I also happen to find one interesting quote when reading Nativescript.
From NativeScript Docs for "smple-ios-background-execution":
iOS doesn't allow a general-purpose background task to run forever, such a task will be suspended by the operating system after approximately 3 minutes. In some special cases your task is allowed to run longer, but you need to use UIBackgroundModes in your Info.plist file to specify the intent of your task (which automatically makes it not general-purpose).
https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html#//apple_ref/doc/uid/TP40007072-CH4-SW23
the simple fetch example is not working in Android....i have follow all the steps but it is not working.Please provide a simple working example of this
Sure, I'll tidy up and include the example project I was using shortly, which worked on both Android and iOS.
Once that is up, @shammus672agmailcom , could you please open a new issue if you are still experiencing problems, as the debugging process is completely different for Android vs iOS.
I've created an example project here: https://github.com/jamesisaac/RNBackgroundTaskExample which includes step by step commits so you can see each part of the setup process.
I haven't tested this exact release of the project on iOS yet (I normally use Windows/Android so a bit of a hassle to get the environment set up), but this is almost identical to the initial code I was using to test the library across both platforms. Maybe you'll spot something you've done differently. I will test it myself shortly on iOS just to confirm everything is still working.
I am facing similar problem, I was also not able to run background task in my iphone background As per documents I have define task but it does not print "Hello from a background task" on console
Below is my version, let me know if it is related to version or device
Node Version: 6.0.0 Npm Version: 3.8.6 Xcode Version: 8.0 react Version: "16.0.0-alpha.12", react-native Version : "0.48.3", react-native-background-fetch Version : "^2.0.8", react-native-background-task Version: "^0.2.1", Device : iphone 5c Device OS: 9.3.3
Same here
Here's one more thing to try, make sure Background Fetch is enabled for the project:
To support this mode, enable the Background fetch option from the Background modes section of the Capabilities tab in your Xcode project. (You can also enable this support by including the UIBackgroundModes key with the fetch value in your app’s Info.plist file.)
Same issue
Hi all, I have a similar issue. My code is working fine on android as background task but ios it is not working.
I checked all permissions and when called statusAsync() is available. All ios background services are enabled and background updates too.
It is not working in debugging and release mode. Another behavior is about background fetch. When I force "Simulate Background Fetch" the Xcode breaks in a line with message SIGSTOP but if I force "continue" event, all will works.
Can you help me?
This worked beautifully on the iOS Simulator with Debug > Background Fetch but couldn't get it to work on a real iOS device. Would love to have this working on the device as well, as it really helped achieve the background process work on the Simulator without many hitches.
This worked beautifully on the iOS Simulator with Debug > Background Fetch but couldn't get it to work on a real iOS device. Would love to have this working on the device as well, as it really helped achieve the background process work on the Simulator without many hitches.
@askarhu Did it work for you? I am stuck in similar situation, it worked well with 'Simulate Background Fetch' on xCode but it doesn't seem to work with production build, I even waited for 2 days, but background fetch was never triggered.
Having the same issue: it is working with the 'Simulate Background Fetch' but when built as release build it was not executed a single time during the past 12 hours...
Like @binitpatel I am also using an older version of this library (as recommended by react-native-background-task):
"react-native-background-fetch": "^2.0.8",
"react-native-background-task": "^0.2.1",
Could it be related to that? Maybe because the capability Background processing is not set? 🤔
Was somebody here able to solve it somehow?