Skip to content

Commit b947883

Browse files
author
Developer
committed
fix: proactively guide user to enable install unknown apps permission
1 parent 502502c commit b947883

1 file changed

Lines changed: 17 additions & 13 deletions

File tree

hooks/useCheckUpdate.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -102,19 +102,23 @@ export function useCheckUpdate() {
102102
await downloadResumable.downloadAsync();
103103
setDownloadProgress(null);
104104

105-
try {
106-
await triggerInstall(localUri);
107-
} catch {
108-
// 无安装未知来源权限,引导用户开启后手动重试
109-
Alert.alert(
110-
'需要安装权限',
111-
'请在打开的设置页中,为 JKVideo 开启「允许安装未知应用」,然后回来再次点击「下载安装」。',
112-
[
113-
{ text: '取消', style: 'cancel' },
114-
{ text: '去设置', onPress: openInstallSettings },
115-
]
116-
);
117-
}
105+
// Android 8.0+ 需要用户在系统设置中为本应用开启「安装未知应用」权限。
106+
// 系统拒绝时不会抛出 JS 异常,因此下载完成后主动引导。
107+
Alert.alert(
108+
'下载完成,准备安装',
109+
'如果点击「安装」后提示无权限,请先点击「去设置」,为 JKVideo 开启「允许安装未知应用」,然后返回重试。',
110+
[
111+
{ text: '去设置', onPress: openInstallSettings },
112+
{
113+
text: '安装',
114+
onPress: () => {
115+
triggerInstall(localUri).catch((e: any) => {
116+
Alert.alert('安装失败', e?.message ?? '请在设置中开启「安装未知应用」权限后重试');
117+
});
118+
},
119+
},
120+
]
121+
);
118122
} catch (e: any) {
119123
setDownloadProgress(null);
120124
Alert.alert('下载失败', e?.message ?? '请稍后重试');

0 commit comments

Comments
 (0)