Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-add-shortcut

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-add-shortcut

React Native Add Shortcut - Adding shortcuts on android

  • 0.28.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

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()

Keywords

FAQs

Package last updated on 02 Jan 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc