Closed julienvincent closed 4 years ago
Hey, as far as I know the only way of doing background running code is natively. The issue is that the app needs to start for the JS bridge to start, so you can't have any running code with JS. You can always do it natively though
@Gustash it must be possible as https://github.com/transistorsoft/react-native-background-geolocation achieves this. When there is an update in location it passes it to the JS to handle.
I don't see any documentation on how to do it. It might be possible, but I haven't figured out how and honestly I don't have a lot of time to figure it out. I'll reopen the issue, but for now I won't be working on it. If you find any good information on how to do it, either send it my way or do a pull request
I will be looking into this some more as I will need this functionality for a personal project. If I can find a way to integrate whatever native functionality I do into this repo I will make a PR to do so.
My brief research into it indicates that one needs to make custom intents, which I don't think is something one can do entirely through this project. It may be possible however to do a combination of registering a shortcut here and creating an intent to trigger it on the native side.
Will get back to you on this
I really appreciate your help
I had a look into it too and I think you're right. Would need to manually create a custom intent extension and link it up with the library to be able to handle background execution. These may be relevant as they both use extensions albeit not intent extension:
https://github.com/matejkriz/react-native-today-widget https://documentation.onesignal.com/docs/react-native-sdk-setup
Took another quick look at this. Seems like it could be possible? This would have to be created by the user though, but it might be possible to offer a template to wire up to the JS. Still don't know if totally possible, but I'll take a look eventually.
Wanna help me on this @DVassilev?
@gustash Sure, will help where I can
A little update on this. I'm pretty sure you can get something working with a mixture of:
https://github.com/jamesisaac/react-native-background-task https://github.com/billmalarky/react-native-queue#example-use-cases https://developer.apple.com/documentation/sirikit/adding_user_interactivity_with_siri_shortcuts_and_the_shortcuts_app?language=objc
I'm a bit busy right now to get an example setup. So if anyone here has some free time I'd appreciate a PR with an example and some documentation for setting it up!
Closing this now as it's out of the scope of this project at the moment and I'm unclear on the details necessary to make this work out of the box
Currently in order to execute a shortcut the app needs to open to the foreground. This removes the possibility to create shortcuts that can run, for example, from the lock screen.
I'm wondering if there is a way currently to allow shortcuts to run in the background? Or if not, what is required in order for this to happen?
P.s, Kudos for the great work so far!