An open API service indexing awesome lists of open source software.

https://github.com/dotnetdreamer/capacitor-plugin-get-app-info

Get the icon, label and more of an app based on its package name.
https://github.com/dotnetdreamer/capacitor-plugin-get-app-info

capacitor capacitor-plugin ionic-framework typescript

Last synced: 5 months ago
JSON representation

Get the icon, label and more of an app based on its package name.

Awesome Lists containing this project

README

        

# Get App Info Plugin

A Capacitor plugin to get the icon and label of an app based on its package name. Same as [https://github.com/esartor/cordova-plugin-get-app-info](https://github.com/esartor/cordova-plugin-get-app-info) but made for Capacitor.

Wanna be practical? check it out in usage [here](https://github.com/dotnetdreamer/notifier).

## Install

```
npm i capacitor-plugin-get-app-info
npx cap sync

```
Register this plugin using add(capacitor.plugin.get.app.info.GetAppInfo.class) in your MainActivity.java like in the following example:

```
this.init(savedInstanceState, new ArrayList>() {{
// Put it here!
add(capacitor.plugin.get.app.info.GetAppInfo.class);
}});
```

## Usage

```
import { Plugins } from '@capacitor/core';
const { GetAppInfo } = Plugins;
//import typing
import { GetAppInfoPlugin } from 'capacitor-plugin-get-app-info';

```

and now get the icon(Base64 string) or app name

```
//icon
try {
const imgRslt = await (GetAppInfo).getAppIcon({
packageName: e.package
});
if(imgRslt.value) {
e.image = imgRslt.value;
}
} catch(e) {
//ignore...
}

//app name
try {
const appName = await (GetAppInfo).getAppLabel({
packageName: e.package
});
if(appName.value) {
e.appName = appName.value;
}
} catch(e) {
//ignore...
}

//launch app
try {
await (GetAppInfo).launchApp({
packageName: 'com.packagename.tolaunch'
});
} catch(e) {
//handle error
}

let canLaunchApp = true;
try {
await (GetAppInfo).canLaunchApp({
packageName: 'com.packagename.tolaunch'
});
} catch(e) {
canLaunchApp = false;
}

//get all available apps
try {
const result = await (GetAppInfo).getAvailableApps();
const apps = JSON.parse(result.applications);
} catch(e) {
this.helperSvc.presentToastGenericError();
}
```

## Supported platforms

* Android

## License
MIT