0.28.0 • Published 5 years ago

react-native-add-shortcut v0.28.0

Weekly downloads
34
License
MIT
Repository
github
Last release
5 years ago

react-native-add-shortcut

Introduction

Library for creating Android App Shortcuts in React Native.

Google Official intro for App Shortcuts

If your app targets Android 7.1 (API level 25) or higher, you can define shortcuts to specific actions in your app. These shortcuts can be displayed in a supported launcher. Shortcuts let your users quickly start common or recommended tasks within your app.

Requirements

  • Android SDK version >= 25
  • React Native >= 0.40

Getting started

$ npm install react-native-add-shortcut --save

Mostly automatic installation

$ react-native link react-native-add-shortcut

Manual installation

Android

  1. Open up android/app/src/main/java/[...]/MainActivity.java
  • Add new AddShortcutPackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
    include ':react-native-add-shortcut'
    project(':react-native-add-shortcut').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-add-shortcut/android')
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
      compile project(':react-native-add-shortcut')
  3. Make sure the android sdk version specify to >= 25 in android/app/build.gradle:

      android {
        compileSdkVersion 25
        buildToolsVersion "25.0.2"
    
        defaultConfig {
            applicationId "com.test"
            minSdkVersion 16
            targetSdkVersion 25
        }

Usage

Import the package

import AddShortcut from 'react-native-add-shortcut';

Add and update App Shortcut

Add Dynamic App Shortcut

AddShortcut.setDynamicShortcuts([
  {
    name: 'Android',
    imageUrl: 'https://sdtimes.com/wp-content/uploads/2017/03/android-1904852_1920.jpg',
    deepLink: 'fb://profile/423556347'
  },
  {
    name: 'Android Studio',
    imageUrl: 'https://sdtimes.com/wp-content/uploads/2018/09/image1a.png',
    deepLink: 'fb://page/346556456'
  },
  {
    name: 'Apple',
    imageUrl: 'https://upload.wikimedia.org/wikipedia/commons/thumb/d/df/Apple-Apple.svg/1000px-Apple-Apple.svg.png',
    deepLink: 'fb://group/234536456'
  }
])

Add Pinned App Shortcut

AddShortcut.setPinnedShortcuts({
    name: 'Apple',
    imageUrl: 'https://upload.wikimedia.org/wikipedia/commons/thumb/d/df/Apple-Apple.svg/1000px-Apple-Apple.svg.png',
    deepLink: 'fb://group/234536456'
})

Options Meaning

NameTypeDescription
nameStringShort label, Long label and ID.
imageUrlStringImage url to fetch for the icons.
deepLinkStringDeep link to open when tapping the shortcut.

Remove All Dynamic Shortcuts

AddShortcut.removeAllDynamicShortcuts()

Get Dynamic Shortcuts - return List<ShortcutInfo>

AddShortcut.getDynamicShortcuts()
0.28.0

5 years ago

0.27.0

5 years ago

0.26.0

5 years ago

0.25.0

5 years ago

0.24.0

5 years ago

0.23.0

5 years ago

0.22.0

5 years ago

0.21.0

5 years ago

0.20.0

5 years ago

0.19.0

5 years ago

0.18.0

5 years ago

0.17.0

5 years ago

0.16.0

5 years ago

0.15.0

5 years ago

0.14.0

5 years ago

0.13.0

5 years ago

0.12.0

5 years ago

0.11.0

5 years ago

0.10.0

5 years ago

0.9.0

5 years ago

0.8.0

5 years ago

0.7.0

5 years ago

0.6.0

5 years ago

0.5.0

5 years ago

0.4.0

5 years ago

0.3.0

5 years ago

0.2.0

5 years ago

0.1.0

5 years ago