forked from joltup/rn-fetch-blob
-
Notifications
You must be signed in to change notification settings - Fork 154
Closed
Labels
Description
rn-fetch-blob isn't working anymore when I upgraded to RN 0.67.4 and target/compile for android 12 (SDK 31). Now, I am trying react-native-blob-util to replace rn-fetch-blob, however it is giving me an error during fetch call. The error I got is similar for both android or iOS.
On iOS I get:
[Error: An SSL error has occurred and a secure connection to the server cannot be made.]
On Android I get:
[Error: ReactNativeBlobUtil request error: java.lang.IllegalStateException: Use of own trust manager but none definedjava.lang.IllegalStateException: Use of own trust manager but none defined]
Any ideas what maybe causing this or suggested changes i should do?
Any input will highly appreciated. Thank you!
- Library versions and config
react-native-blob-util 0.16.0
react-native 0.67.4
Android build.gradle: Compile and target SDK: 31 - Sample code
import ReactNativeBlobUtil from "react-native-blob-util";
import { Platform, PermissionsAndroid } from "react-native";
...
let allPermissionsGranted = false;
if (Platform.OS === "android") {
const granted = await PermissionsAndroid.requestMultiple([
PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE,
PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,
]);
allPermissionsGranted =
granted["android.permission.READ_EXTERNAL_STORAGE"] === "granted" && granted["android.permission.WRITE_EXTERNAL_STORAGE"] === "granted";
}
try {
const res = await ReactNativeBlobUtil.config({
trusty: true,
fileCache: false,
path: directory + "/" + filename,
}).fetch("GET", docUrl, headers);
const status = res.info().status;
if (status === 200) {
if (Platform.OS === "ios") {
ReactNativeBlobUtil.ios.openDocument(res.path());
} else {
if (allPermissionsGranted) {
const android = ReactNativeBlobUtil.android;
android.actionViewIntent(res.path(), mimetype);
}
}
}
} else {
console.log("Error fetching file");
throw new Error("...")
}
} catch (e) {
console.error(e);
}