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.
- Host: GitHub
- URL: https://github.com/dotnetdreamer/capacitor-plugin-get-app-info
- Owner: dotnetdreamer
- Created: 2020-11-20T08:13:42.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-04-26T19:58:40.000Z (about 3 years ago)
- Last Synced: 2024-11-12T21:02:13.371Z (6 months ago)
- Topics: capacitor, capacitor-plugin, ionic-framework, typescript
- Language: Java
- Homepage:
- Size: 73.2 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
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