npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@shengkai/react-native-apk-manager

v1.1.0

Published

React Native bridging library for android to manager apk.(install apk, uninstall apk, open apk, check app is installed or not, check app is installed or not with channel)

Downloads

11

Readme

react-native-apk-manager

React Native bridging library for android to manager apk.(install apk, uninstall apk, open apk, check app is installed or not, check app is installed or not with channel)

TOC

Installation

Using npm:

npm install --save react-native-apk-manager

or using yarn:

yarn add react-native-apk-manager

Linking

Automatic

react-native link react-native-apk-manager

(or using rnpm for versions of React Native < 0.27)

rnpm link react-native-apk-manager

Manual

  • optional in android/build.gradle:
...
  ext {
    // dependency versions
    compileSdkVersion = "<Your compile SDK version>" // default: 27
    targetSdkVersion = "<Your target SDK version>" // default: 27
  }
...
  • in android/app/build.gradle:
dependencies {
    ...
    compile "com.facebook.react:react-native:+"  // From node_modules
+   compile project(':react-native-apk-manager')
}
  • in android/settings.gradle:
...
include ':app'
+ include ':react-native-apk-manager'
+ project(':react-native-apk-manager').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-apk-manager/android')

With React Native 0.29+

  • in MainApplication.java:
+ import com.superhao.react_native_apk_manager.ApkManagerPackage;

  public class MainApplication extends Application implements ReactApplication {
    ......

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
+         new ApkManagerPackage(),
          new MainReactPackage()
      );
    }

    ......
  }

Usage

import * as ApkManager from 'react-native-apk-manager';

API

| Method | Params | Return Type | | :----- | :------ | :---------- | | isAppInstalled() | pageName<string> | Promise<boolean> | | isAppsInstalled() | packageNames<Array<string>> | Promise<Array<boolean>> | | installApk() | filePath<string> | void | | uninstallApk() | packageName<string> | void | | openApk() | packageName<string> | void | | isExpChannel() | packageName<string>, metaDataName<string>, channel<string> | Promise<boolean> | | isExpChannels() | packageNames<Array<string>>, metaDataNames<Array<string>>, channels<Array<string>> | Promise<Array<boolean>> | | getAPKInfomation() | apkFile<string> | Promise<Object> | | getAppInformation() | packageName<string> | Promise<Object> | | getAppMetaDataByKey() | packageName<string>, key<string> | Promise<string> | | getInstalledAppInfo() | null | Promise<Array<Object>> |

isAppInstalled(pageName<string>): Promise<boolean>

Check app isInstalled with packageName.

Examples

ApkManager.isAppInstalled('com.lengjing.ktyaokongc').then((data)=> {
  // true or false
});

isAppsInstalled(packageNames<Array<string>>):Promise<Array<boolean>>

Check apps isInstalled with packageName List.

Examples

ApkManager.isAppInstalled(['com.lengjing.ktyaokongc', 'test.tets', 'xxxx', 'xxxx']).then((data)=> {
  // [true, false, false, true]
});

installApk(filePath<string>)

Install apk with apkFilePath.

Examples

ApkManager.installApk('storage/emulated/0/renlaifeng_download/test.apk');

uninstallApk(packageName<string>)

Uninstall apk with packageName.

Examples

ApkManager.uninstallApk('com.lengjing.ktyaokongc');

openApk(packageName<string>)

Open other app with packageName.

Examples

ApkManager.openApk('com.lengjing.ktyaokongc');

isExpChannel(packageName<string>, metaDataName<string>, channel<string>):Promise<boolean>

Check special channel app is installed with packageName, metaName, special channel.

  • Before use, you should know app's metaName and channel in AndroidManifest.xml.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.ownmoduletest"> => // here is the packageName 'com.ownmoduletest'
    ...
    <application
      ...
      <meta-data android:name="JPUSH_APPKEY" android:value="1232444"/> => // here is the metaDataName 'JPUSH_APPKEY'
      ...
    </application>
</manifest>

Examples

ApkManager.isExpChannel('com.ownmoduletest', 'JPUSH_APPKEY', '1232444').then((data)=> {
  // true
});

ApkManager.isExpChannel('com.ownmoduletest', 'JPUSH_APPKEY', '11111').then((data)=> {
  // false
});

ApkManager.isExpChannel('com.ownmoduletest', 'otherkeyname', '1232444').then((data)=> {
  // false
});

isExpChannels(packageNames<Array<string>>, metaDataNames<Array<string>>, channels<Array<string>>):Promise<Array<boolean>>

Check special channel apps is installed with packageNames, metaNames, special channels.

  • Before use, you should know app's metaName and channel in AndroidManifest.xml.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.ownmoduletest"> => // here is the packageName 'com.ownmoduletest'
    ...
    <application
      ...
      <meta-data android:name="JPUSH_APPKEY" android:value="1232444"/> => // here is the metaDataName 'JPUSH_APPKEY'
      ...
    </application>
</manifest>

Examples

ApkManager.isExpChannels(['com.ownmoduletest', 'com.test', 'xxxxxx'], ['JPUSH_APPKEY', 'test_key', 'xxxxxxx'], ['1232444', 'wanted channel', 'wanted channel']).then((data)=> {
  // [true, true, true]
});

ApkManager.isExpChannels(['com.ownmoduletest', 'com.test', 'xxxxxx'], ['JPUSH_APPKEY', 'test_key', 'xxxxxxx'], ['11111', 'wanted channel', 'wanted channel']).then((data)=> {
  // [false, true, true]
});

ApkManager.isExpChannels(['com.ownmoduletest', 'com.test', 'xxxxxx'], ['other_key', 'test_key', 'xxxxxxx'], ['1232444', 'wanted channel', 'wanted channel']).then((data)=> {
  // [false, true, true]
});

getAPKInformation(apkFile<string>): Promise<Object>

Get apk information with apk file path. You can get appName, packageName, versionName, versionCode, installLocation, firstInstallTime, lastUpdateTime.

Examples

   ApkManager.getAPKInfomation('/storage/emulated/0/renlaifeng_download/app-release .apk').then((data)=>{
      console.log(data);
      // {appName: "test", packageName: "com.test", versionName: "1.0.0", versionCode: "1", installLocation: 0, firstInstallTime: 0, lastUpdateTime: 0}
    }).catch((error)=>{
      console.log(error);
      // 400 Get ApkInfomation Fail
    });

getAppInformation(packageName<string>): Promise<Object>

Get app information with packageName. You can get appName, packageName, versionName, versionCode, installLocation, firstInstallTime, lastUpdateTime.

Examples

    ApkManager.getAppInfomation('com.test').then((data)=>{
      console.log(data);
      // {appName: "test", packageName: "com.test", versionName: "1.0.0", versionCode: "1", installLocation: 0, firstInstallTime: 123234456, lastUpdateTime: 123234456}
    }).catch((error)=>{
      console.log(error);
      // 400 Get AppInfomation Fail
    });

getAppMetaDataByKey(packageName<string>, key<string>): Promise<string>

Get app information with packageName and key(metadata name).

  • Before use, you should know app's packageName and key(metadata name) in target AndroidManifest.xml.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.test"> => // here is the packageName 'com.test'
    ...
    <application
      ...
      <meta-data android:name="JPUSH_APPKEY" android:value="1232444"/> => // here is the metaDataName 'JPUSH_APPKEY'
      <meta-data android:name="JPUSH_CHANNEL" android:value="test"/> => // here is the metaDataName 'JPUSH_CHANNEL'
      ...
    </application>
</manifest>

Examples

    ApkManager.getAppMetaDataByKey('com.test', 'JPUSH_CHANNEL').then((data)=>{
      console.log(data);
      // test
    }).catch((error)=>{
      console.log(error);
      // Not Found MetaData
    });
    
    ApkManager.getAppMetaDataByKey('com.test', 'JPUSH_APPKEY').then((data)=>{
      console.log(data);
      // 1232444
    }).catch((error)=>{
      console.log(error);
      // Not Found MetaData
    });

getInstalledAppInfo(): Promise<Array<Object>>

Get all your installed app information. You can get appName, packageName, versionName, versionCode, installLocation, firstInstallTime, lastUpdateTime.

Examples

    ApkManager.getInstalledAppInfo().then((data)=>{
      console.log(data);
      /* [
      {appName: "installedApp", packageName: "com.installedApp", versionName: "1.0.0", versionCode: "1", installLocation: 0, firstInstallTime: 123234456, lastUpdateTime: 123234456},
      {appName: "installedApp1", packageName: "com.installedApp1", versionName: "1.0.0", versionCode: "1", installLocation: 0, firstInstallTime: 123234456, lastUpdateTime: 123234456},
      {appName: "installedApp2", packageName: "com.installedApp2", versionName: "1.0.0", versionCode: "1", installLocation: 0, firstInstallTime: 123234456, lastUpdateTime: 123234456}
      ]
      */
    }).catch((error)=>{
      console.log(error);
      // 400 Get AppInfomation Fail
    });