Skip to content

Commit

Permalink
fix(android): fix upload when targeting Android >= 34
Browse files Browse the repository at this point in the history
  • Loading branch information
ThibaultBee committed Dec 18, 2023
1 parent e4812a0 commit 032a178
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ cd ios && pod install
```js
import ApiVideoUploader from '@api.video/react-native-video-uploader';

ApiVideoUploader.uploadWithUploadToken('MY_VIDEO_TOKEN', 'my-video.mp4')
ApiVideoUploader.uploadWithUploadToken('YOUR_UPLOAD_TOKEN', 'path/to/my-video.mp4')
.then((value: Video) => {
// Manages success here
})
Expand All @@ -70,6 +70,16 @@ Permissions `android.permission.READ_MEDIA_VIDEO` (for API 33+) or `android.perm

On Android 33+, the upload comes with a notification to show the progress. So if your application targets Android 33+, you might request `android.permission.POST_NOTIFICATIONS` permission at runtime.

When targeting Android API Level 34+, you must declare the service type in your application's manifest file.
In your `AndroidManifest.xml` file, add the following lines in the `<application>` tag:

```xml
<service
android:name="androidx.work.impl.foreground.SystemForegroundService"
android:foregroundServiceType="location|dataSync"
tools:node="merge" />
```

### Notifications

To customize the notification to your own brand, you can change the icon, color or channel name by overwriting the following resources in your own application resources:
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ dependencies {
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+"

implementation 'video.api:android-video-uploader:1.3.1'
implementation 'video.api:android-video-uploader:1.3.3'
implementation 'androidx.work:work-runtime-ktx:2.8.1'
}

Expand Down
2 changes: 2 additions & 0 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@
android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC"/>
</manifest>
8 changes: 7 additions & 1 deletion example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
Expand Down Expand Up @@ -27,6 +28,11 @@
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />

<service
android:name="androidx.work.impl.foreground.SystemForegroundService"
android:foregroundServiceType="location|dataSync"
tools:node="merge" />
</application>

</manifest>

0 comments on commit 032a178

Please sign in to comment.