Coder Social home page Coder Social logo

amantura / react-native-launcher-kit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from louaysleman/react-native-launcher-kit

0.0 0.0 0.0 994 KB

License: MIT License

JavaScript 1.16% Ruby 2.94% C++ 13.19% Objective-C 4.32% Java 46.80% TypeScript 21.97% Objective-C++ 8.03% CMake 0.50% Starlark 1.09%

react-native-launcher-kit's Introduction

react-native-launcher-kit

This is a React Native package for Android that provides a set of helper functions for launching apps and interacting with the launcher. It works with automatic linking on React Native versions 0.60 and higher. For older versions, manual linking is required.

Installation

npm install react-native-launcher-kit
yarn add react-native-launcher-kit

If you're using React Native 0.60 or higher, the package will be automatically linked for you. For older versions, you need to manually link the package.

Manual Linking
  1. In your project directory, run the following command:
react-native link react-native-launcher-kit
  1. Open the android/app/build.gradle file in your project and add the following line to the dependencies section:
implementation
project(':react-native-launcher-kit')
  1. Open the MainApplication.java file in your project and add the following import statement:
import com.launcherkit;
  1. Add the package to the list of packages in the getPackages() method:
protected List<ReactPackage> getPackages(){
  return Arrays.asList(
  new MainReactPackage(),
  new LauncherKit() // <-- Add this line
  );
  }

Features

The features of the React Native Launcher Kit include:

  1. Get all installed apps (sorted and unsorted).
  2. Get the current default launcher.
  3. Get the current battery percentage and whether the phone is charging or not.
  4. Check if a package (bundle ID) is installed.
  5. Open system settings.
  6. Open "Set as default launcher" screen directly.
  7. Open an app using its bundle ID.
  8. Open the alarm app directly.

Demo

Methods

1. getApps(): AppDetail[]

Returns an array of all installed apps on the device.

import { InstalledApps } from 'react-native-launcher-kit';

const result = InstalledApps.getApps();

2. getSortedApps(): AppDetail[]

Returns an array of all installed apps on the device, sorted alphabetically by app label.

import { InstalledApps } from 'react-native-launcher-kit';

const result = InstalledApps.getSortedApps();

AppDetail Interface

interface AppDetail {
  label: string;
  packageName: string;
  icon: string; // base64
}

3. launchApplication

A helper function allow you to launcher application using bundle ID.

import { RNLauncherKitHelper } from 'react-native-launcher-kit';

RNLauncherKitHelper.launchApplication('com.example.louay')

4. checkIfPackageInstalled: Promise<boolean>

Checks if an app with the given bundle ID is installed on the device.

import { RNLauncherKitHelper } from 'react-native-launcher-kit';

const result = await RNLauncherKitHelper.checkIfPackageInstalled(
  'com.android.settings',
);
console.log(result); // true or false.

5. getDefaultLauncherPackageName: Promise<string>

Checks the default launcher app on the device.

import { RNLauncherKitHelper } from 'react-native-launcher-kit';

const result = await RNLauncherKitHelper.getDefaultLauncherPackageName();
console.log(result);

6. openSetDefaultLauncher: Promise<boolean>

Opens the "Set Default Launcher" screen on the device.

import { RNLauncherKitHelper } from 'react-native-launcher-kit';

const result = await RNLauncherKitHelper.openSetDefaultLauncher();
console.log(result); // true or false.

7. getBatteryStatus: Promise<BatteryStatus>

Returns the current battery status of the device and if the phone is currently charging or not.

import { RNLauncherKitHelper } from 'react-native-launcher-kit';

const result = await RNLauncherKitHelper.getBatteryStatus();
console.log(result); // {"isCharging": false, "level": 100}

BatteryStatus Interface

interface AppDetail {
  level: number;
  isCharging: boolean;
}

8. openAlarmApp: boolean

Opens the default alarm app on the device.

import { RNLauncherKitHelper } from 'react-native-launcher-kit';

const result = await RNLauncherKitHelper.getBatteryStatus();
console.log(result);

9. goToSettings

Opens the settings screen of the device.

import { RNLauncherKitHelper } from 'react-native-launcher-kit';

RNLauncherKitHelper.goToSettings();

Demo App

React-Native-Launcher-Kit has been utilized for testing purposes on a launcher known as NoPhoneLauncher. You can experience its functionality in real-time by accessing it on Google Play via the following link.

Example App

You can experience the functionality of the code by exploring the examples provided in our GitHub repository, which can be accessed from the following link.

License

MIT


react-native-launcher-kit's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.