Vydia / react-native-background-upload

Upload files in your React Native app even while it's backgrounded. Supports Android and iOS, including camera roll assets.
MIT License
735 stars 335 forks source link

Support of Android 8.1 and above #164

Open Diwei-Chen opened 5 years ago

Diwei-Chen commented 5 years ago

Followed the solution as proposed in https://github.com/Vydia/react-native-background-upload/issues/59

After turning off the notification setting, now Android is throwing:

Error: Android Oreo requires a notification configuration for the service to run. https://developer.android.com/reference/android/content/Context.html#startForegroundService(android.content.Intent)

The targetSdkVersion in our android/app/build.gradle is 27 and compileSdkVersion is 28.

We found some solutions on stack overflow https://stackoverflow.com/questions/47531742/startforeground-fail-after-upgrade-to-android-8-1 but not sure if we're doing the right thing.

Any ideas, please?

Related documentation: https://developer.android.com/reference/android/content/Context.html#startForegroundService(android.content.Intent)

NicholasIoanJones commented 4 years ago

We are having the same issue. @Diwei-Chen did you solve this satisfactorily? Could you share how?

Maintainers - would be good to include instructions for configuring this in Android > 8.1

reime005 commented 4 years ago

AFAIK it should be enough to enable the notification, by setting options: { notification: { enabled: true ... } when doing an upload

Diwei-Chen commented 4 years ago

@NicholasIoanJones I am sorry to tell but without enough knowledge to help improve the Android code, we ended up with replacing this package with the fetch method in rn-fetch-blob in the sacrifice of background upload capability on Android.

elgrones commented 4 years ago

I solved my problem adding this line <uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> in my android manifest