简体   繁体   English

离子在带有图标的安卓设备上安装应用程序

[英]Ionic get installed apps on android device with icon

I know this question is already asked but I have problem in that solution which is not answered there.我知道已经有人问过这个问题,但我在该解决方案中遇到了问题,但没有在那里回答。

I used this plugin but this gives me error:我使用了这个插件,但这给了我错误:

var success = function (app_list) { alert(JSON.stringify(app_list)); };
var error = function (app_list) { alert("Oopsie! " + app_list); };
Applist.createEvent('', '', '', '', '', success, error)

How can I remove this error?我怎样才能消除这个错误? I downloaded it running:我下载它运行:

npm i cordova-plugin-applist

Error message:错误信息:

Cannot find name 'Applist'

Add添加

import * as Applist from 'cordova-plugin-applist2/www/Applist.js';
import { Platform } from '@ionic/angular';

to your component .ts file到您的组件 .ts 文件

Then to use it in probably constructor然后在可能的构造函数中使用它

constructor(public platform: Platform) {
  platform.ready().then(
    function(){
      if(platform.is('android') && !platform.is('mobileweb')){
          var success = function(app_list) { 
            //success function
            console.log(app_list);
           };
          var error = function(app_list) {  
            //error          
            console.log("An Error occured while fetching App Lists");
            console.error(app_list);
          };
          //for the date parameters, any date is okay, 
          //the first date should be in the past
          Applist.createEvent('', '', '', new Date(1999, 10, 11, 12, 12, 12, 12), new Date(), success, error);
      }
    }
  );
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM