mirror of
https://gitcode.com/gh_mirrors/re/react-native-pushy.git
synced 2025-09-18 01:56:11 +08:00
Fix install apk under android 7
This commit is contained in:
19
lib/index.js
19
lib/index.js
@@ -3,7 +3,12 @@ import {
|
||||
getCheckUrl,
|
||||
setCustomEndpoints,
|
||||
} from './endpoint';
|
||||
import { NativeEventEmitter, NativeModules, Platform } from 'react-native';
|
||||
import {
|
||||
NativeEventEmitter,
|
||||
NativeModules,
|
||||
Platform,
|
||||
PermissionsAndroid,
|
||||
} from 'react-native';
|
||||
export { setCustomEndpoints };
|
||||
const {
|
||||
version: v,
|
||||
@@ -197,6 +202,18 @@ export function markSuccess() {
|
||||
|
||||
export async function downloadAndInstallApk({ url, onDownloadProgress }) {
|
||||
logger('downloadAndInstallApk');
|
||||
if (Platform.OS === 'android' && Platform.Version <= 23) {
|
||||
try {
|
||||
const granted = await PermissionsAndroid.request(
|
||||
PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,
|
||||
);
|
||||
if (granted !== PermissionsAndroid.RESULTS.GRANTED) {
|
||||
return;
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn(err);
|
||||
}
|
||||
}
|
||||
let hash = Date.now().toString();
|
||||
let progressHandler;
|
||||
if (onDownloadProgress) {
|
||||
|
Reference in New Issue
Block a user