Giter VIP home page Giter VIP logo

react-native-springboard-shortcuts's Introduction

React Native Springboard Shortcuts

React Native Springboard Shortcuts provides an easy way to create shortcuts to an application when developing in React Native.

The shortcuts can deeplink to a specific screen(s) inside your app. This library take advantage of the native side with a simple API for the JavaScript side. At the moment the library only supports shortcuts for Android devices, in the future we may add support for iOS as well.

Requirements

  • Android SDK version >= 25

Getting started

$ npm install --save react-native-springboard-shortcuts

Manual installation

Android

  1. Open up android/app/src/main/java/[...]/MainApplication.java
  • Add import com.alon.ReactNativeSpringboardShortcuts.RNSpringboardShortcutsPackage; to imports at the top of the file
  • Add new RNSpringboardShortcutsPackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
     include ':react-native-springboard-shortcuts'
     project(':react-native-springboard-shortcuts').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-springboard-shortcuts/lib/android')
    
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
     implementation project(":react-native-springboard-shortcuts")
    

Example

import RNSpringboardShortcuts from 'react-native-springboard-shortcuts';

RNSpringboardShortcuts.isShortcutServiceAvailable((isAvailable: boolean) => {

  if (isAvailable) {
    const shortcut = {
      id: 'shortcut.id.example',
      shortLabel: 'Shortcut title',
      longLabel: 'Shortcut description',
      imageUrl: 'https://someImage.jpg',
      intentUri: `myApp://myCoolAppScreen`
    };

    RNSpringboardShortcuts.exists(shortcut.id).then(() => {
      // Exists
      RNSpringboardShortcuts.updateShortcut(shortcut);
    }).catch((_err: Error) => {
      // Does not exist
      RNSpringboardShortcuts.addShortcut(shortcut);
    });
   }
});

API

isShortcutServiceAvailable

RNSpringboardShortcuts.isShortcutServiceAvailable((isAvailable: boolean) => {

});

exists

RNSpringboardShortcuts.exists(shortcut.id).then(() => {
  // Exists
}).catch((_err: Error) => {
  // Does not exist
});

addShortcut

RNSpringboardShortcuts.addShortcut(shortcut);

updateShortcut

RNSpringboardShortcuts.updateShortcut(shortcut);

removeShortcut

RNSpringboardShortcuts.removeShortcut(shortcut.id);

removeAllShortcuts

RNSpringboardShortcuts.removeAllShortcuts();

handleShortcut

This function will only work if you did NOT provide an intentUri to the shortcut. To use this method for handling shortcuts, copy it to componentDidMount function of a component/screen which loads at the start of your app.

RNSpringboardShortcuts.handleShortcut((shortcutId: string) => {

});

So what are you waiting for? Now that you know how to use it, start implementing React Native Springboard Shortcuts in your project today!

react-native-springboard-shortcuts's People

Contributors

buttershub avatar github-sheriff avatar kgshv avatar silyevsk avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

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.