These days gone update apk destruction ionic 4, away galaxy detours, here to share
First, please go to https://www.cnblogs.com/loaderman/p/11333193.html
If you have a problem then please watch this article
When you download does not respond, if you can not get from the server to request, review the url is correct
At the same time more than Android9.0 phone will not connect http, https only be used, please use https server, download the domain name when using https download
If you can get a request from the server to download the plug and replace Downloader
1 ionic cordova plugin add integrator-cordova-plugin-downloader
2 npm install @ionic-native/downloader
In the module.ts
1 import { Downloader } from '@ionic-native/downloader/ngx';
2 providers: [
3 ...
4 Downloader,
5 ...]
In downloadApp () in the code
. 1 var Request: DownloadRequest = {
2 URI: 'HTTPS: //url/test.apk',
. 3 title: 'the Download', // download task name
. 4 Description: '',
. 5 mimeType: '',
. 6 visibleInDownloadsUi: to true ,
. 7 notificationVisibility: NotificationVisibility.VisibleNotifyCompleted,
. 8 destinationInExternalFilesDir: {
. 9 dirType: 'the Download', // download folder name
10 subPath: 'test.apk' // downloaded APK
. 11 }
12 is };
13
14
15 let options: DocumentViewerOptions = {
16 title: 'MyApp'
17 }
18 this.downloader.download(request)
19 .then((location: string) =>
20 this.fileOpener.showOpenWithDialog(location, 'application/vnd.android.package-archive')//此处location为当前手机下载的地址
21 .then(() => alert('File is opened'))
22 .catch(e => console.log('Error opening file', e)))
23 .catch((error: any) => alert(error));
Download your problem solving may also find that you can not directly open the downloaded apk be local (Huawei cell phone issue will be the pro-test) installation
You need to add platforms \ android \ app \ src main in AndroidManifest.xml \ in
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
These are the bloggers met a few questions, I hope you can help