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

@rn-bridge/react-native-shortcuts

v0.4.0

Published

React native library for android shortcuts and iOS quick actions which allow users to quickly access specific app functionalities directly from the home screen or app icon.

Downloads

77

Readme

npm React Native Android iOS

@rn-bridge/react-native-shortcuts

Android Shortcuts and iOS Quick Actions are features that allow users to quickly access specific app functionalities directly from the home screen or app icon, enhancing user experience by providing fast access to common tasks.

Fully compatible with TypeScript.

Example

| Android | iOS | |---|---| | | |

Supported platforms

| Platform | Support | |---|---| | iOS | ✅ | | Android | ✅ | | Web | ❌ | | Windows | ❌ | | macOS | ❌ |

Installation

npm install @rn-bridge/react-native-shortcuts

or

yarn add @rn-bridge/react-native-shortcuts

Setup

iOS

Add the following code to your AppDelegate.m

#import "RNShortcuts.h"
- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL))completionHandler {
  [RNShortcuts handleShortcutItem:shortcutItem];
  completionHandler(YES);
}

Android

No setup needed

Summary

Methods

| Name | Description | | --- | --- | | addShortcut | Adds the shortcut(android), quick action(ios) for the given details. | | updateShortcut | Updates the shortcut or quick action details. | | removeShortcut | Removes the specific shortcut. For android in case if the user changes your app shortcut to pinned shortcut, app shortcut will be removed but pinned shortcut will be still visible but in disabled state. This shortcut is no longer valid and is not clickable. | | removeAllShortcuts | Removes all the shortcuts. For android in case if the user changes your app shortcuts to pinned shortcuts, app shortcuts will be removed but pinned shortcuts will be still visible but in disabled state. These shortcuts are no longer valid and are not clickable. | | getShortcutById | Returns the shortcut details such as id, title, longLabel, subtitle. | | isShortcutExists | Returns whether the shortcut is registered with given id. | | isShortcutSupported | Returns whether your device supports shortcuts(android), quick actions(ios). | | getInitialShortcutId | If the initial app launch was triggered by a shortcut, it will give the id of that shortcut, otherwise it will give null. | | addOnShortcutUsedListener | If the app is in background and the app is launchced by a shortcut, it will give the id of that shortcut. | | removeOnShortcutUsedListener | Removes the listener. You app no longer receives events. |

Usage

Import

import Shortcuts from '@rn-bridge/react-native-shortcuts';

isShortcutSupported

const response = await Shortcuts.isShortcutSupported() // true or false

| Platform | Supported Version | |---|---| | iOS | >=9.0 | | Android | >=7.1 (API Level 25) |

addShortcut

const response = await Shortcuts.addShortcut({
  id: "a426a46b-7389-431c-9ea8-8b370e0c65fc",
  title: "Open App",
  iconName: "app_shortcut"
})

Response:

{
  "id": "a426a46b-7389-431c-9ea8-8b370e0c65fc",
  "title": "Open App"
}

Supported options: | Key | Platform | Required | Description | | --- | --- | --- | --- | | id | Both | Yes | A required, app-specific string that you employ to identify the shortcut. | | title | Both | Yes | The required, user-visible title for the Home Screen shortcut. | | longLabel | Android | No | An extended phrase that describes the shortcut's purpose. If there's enough space, the launcher displays this value instead of title. When possible, limit this long description to 25 characters. | | subtitle | iOS | No | The user-visible subtitle for the Home Screen dynamic quick action. | | iconName | Both | No | The icon for the Home Screen shortcut. Icon name should be the name of your iOS asset or Android drawable. Refer iOS Android resource addition. |

updateShortcut

const response = await Shortcuts.updateShortcut({
  id: "a426a46b-7389-431c-9ea8-8b370e0c65fc",
  title: "Open App",
  iconName: "app_shortcut"
})

Response:

{
  "id": "a426a46b-7389-431c-9ea8-8b370e0c65fc",
  "title": "Open App"
}

Supported options: | Key | Platform | Required | Description | | --- | --- | --- | --- | | id | Both | Yes | The shortcut id which you want to update. | | title | Both | Yes | The required, user-visible title for the Home Screen shortcut. | | longLabel | Android | No | An extended phrase that describes the shortcut's purpose. If there's enough space, the launcher displays this value instead of title. When possible, limit this long description to 25 characters. | | subtitle | iOS | No | The user-visible subtitle for the Home Screen dynamic quick action. | | iconName | Both | No | The icon for the Home Screen shortcut. Icon name should be the name of your iOS asset or Android drawable. Refer iOS Android resource addition. |

removeShortcut

const response = await Shortcuts.removeShortcut("a426a46b-7389-431c-9ea8-8b370e0c65fc") // true or false

Supported options: | Key | Platform | Required | Description | | --- | --- | --- | --- | | id | Both | Yes | The shortcut id which you want to remove. |

removeAllShortcuts

const response = await Shortcuts.removeAllShortcuts() // true or false

isShortcutExists

const response = await Shortcuts.isShortcutExists("a426a46b-7389-431c-9ea8-8b370e0c65fc") // true or false

Supported options: | Key | Platform | Required | Description | | --- | --- | --- | --- | | id | Both | Yes | The shortcut id which you want to check. |

getShortcutById

const response = await Shortcuts.getShortcutById("a426a46b-7389-431c-9ea8-8b370e0c65fc") // true or false

Response:

{
  "id": "a426a46b-7389-431c-9ea8-8b370e0c65fc",
  "title": "Open App",
  "longLable": "...",
  "subtitle": "..."
}

Supported options: | Key | Platform | Required | Description | | --- | --- | --- | --- | | id | Both | Yes | The shortcut id which you want to get. |

getInitialShortcutId

If the initial app launch was triggered by a shortcut, it will give the id of that shortcut, otherwise it will give null.

const callback = (id) => {
  console.log('Shortcut Id:', id);
};

const id = await Shortcuts.getInitialShortcutId();

addOnShortcutUsedListener

If the app is in background and the app is launchced by a shortcut, it will give the id of that shortcut.

const callback = (id) => {
  console.log('Shortcut Id:', id);
};

Shortcuts.addOnShortcutUsedListener(callback);

removeOnShortcutUsedListener

Shortcuts.removeOnShortcutUsedListener();

How To Run Example App ?

To run example app, follow the below steps

  1. Clone the repository
  2. Do yarn install
  3. Next navigate to example folder i.e cd example
  4. Do yarn install
  5. Next navigate to ios folder i.e cd ios and do pod install, then cd ..
  6. For android run yarn android
  7. For ios run yarn ios