alinz / react-native-share-extension

react-native as an engine to drive share extension
MIT License
763 stars 398 forks source link

Running in the background #121

Open cdn34 opened 5 years ago

cdn34 commented 5 years ago

Is there a way to make sure the code execution in the extension finishes when the extension is closed on iOS?

I managed to get this working on Android using a Foreground service, but on iOS the behaviour seems a bit random, sometimes it continues the execution and other times it doesn't (most of the times it fails when using a slower connection, 3G or worse).

Also for the extension, background modes don't seem to be available.

Any help would be appreciated.

AndrewHenderson commented 5 years ago

@cdn34 This is probably due to the timeout restriction on iOS. I read in this tutorial that iOS has a 30 second timeout on background requests. On a slow connection, the request is likely canceled. Depending on how far along it is, you might find the server received the request successfully, even if the client thinks it failed due to timeout.

frenberg commented 5 years ago

We're using react-native-background-timer for fetch requests when the app goes into background. Haven't tried it in an extension, but maybe it will work here too.