UNPKG

react-native-malwarelytics

Version:

Malwarelytics for React Native protects your banking or fintech app from a broad range of mobile security threats with an industry-leading mobile threat intelligence solution.

59 lines (44 loc) 2.55 kB
# App Info The App Info feature is currently supported only on the Android platform. Therefore, before you start using it, ensure that the functionality is available: ```typescript import { Platform } from 'react-native'; if (Platform.OS !== 'android') { throw new Error("App Info is not supported on this platform") } ``` The feature provides a utility method for obtaining information about an application installed on the device. This is useful when you need to display additional details about the app in your UI. ## Obtaining App Info To get information about a specific application, you can use the `getAppInfo` method. You need to provide the package name of the app you're interested in. ```typescript import { Malwarelytics, AppInfo } from 'react-native-malwarelytics'; async function logAppInfo(packageName: string) { const appInfo: AppInfo | null = await Malwarelytics.sharedInstance.getAppInfo(packageName); if (appInfo) { console.log(`App Name: ${appInfo.appName}`); console.log(`Package Name: ${appInfo.packageName}`); // The icon is a Base64 encoded PNG string. // You can use it in the <Image> component for the source parameter. } else { console.log(`Application with package name ${packageName} was not found.`); } } ``` By default, the method doesn't retrieve the list of permissions required by the application. If you need this information, you can pass an optional boolean parameter: ```typescript const withPermissions = true; const appInfo: AppInfo | null = await Malwarelytics.sharedInstance.getAppInfo("com.example.app", withPermissions); if (appInfo) { console.log(`Permissions: ${appInfo.permissions.join(', ')}`); } ``` ### The AppInfo Object The `getAppInfo` method returns a promise that resolves to an `AppInfo` object or `null` if the application is not found. The `AppInfo` object has the following structure: | Property | Type | Description | |---------------|----------|-------------------------------------------------------------| | `packageName` | `string` | The application's package name (Application ID). | | `appName` | `string` | The application's name, localized to the current device. | | `icon` | `string` | A Base64 encoded PNG string of the application's icon. | | `permissions` | `string[]` | A list of permissions the application requires. | ## Read Next - [Antivirus Module](Usage-AV.md) - [RASP Module](Usage-RASP.md)