fix: (MM-59956) Android crash when sharing (#8122)

This commit is contained in:
Rahim Rahman 2024-08-02 09:05:52 -06:00 committed by GitHub
parent 1c66504b66
commit 1de7b5e9b7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 1 deletions

View file

@ -21,6 +21,7 @@
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC"/>
<!-- Request legacy Bluetooth permissions on older devices. -->
<uses-permission android:name="android.permission.BLUETOOTH"
@ -116,5 +117,15 @@
android:foregroundServiceType="microphone"
android:exported="false"
/>
<!-- Android 14 requires the correct Foreground Service (FGS) type for RNShare -->
<service
android:name="androidx.work.impl.foreground.SystemForegroundService"
android:foregroundServiceType="dataSync"
android:exported="false"
android:stopWithTask="false"
tools:node="merge"
/>
</application>
</manifest>

View file

@ -1,5 +1,6 @@
package com.mattermost.rnshare
import android.content.pm.ServiceInfo
import android.content.Context
import android.util.Base64
import android.util.Log
@ -198,7 +199,7 @@ class ShareWorker(private val context: Context, workerParameters: WorkerParamete
.setSmallIcon(applicationContext.resources.getIdentifier("ic_notification", "mipmap", applicationContext.packageName))
.setOngoing(true)
.build()
return ForegroundInfo(1, notification)
return ForegroundInfo(1, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC)
}
}