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

react-native-app-quick-actions

v0.1.6

Published

ReactNative Quick Actions for Android & iOS

Downloads

14

Readme

react-native-app-quick-actions

ReactNative App Quick Actions for Android & iOS. Inspired by Expo Quick Actions & react-native-actions-shortcuts. Supports both Old (Native Module) and New (Turbo Module) Architecture of ReactNative

Installation

yarn install react-native-app-quick-actions

or

npm install react-native-app-quick-actions

iOS

iOS Requires one additional step to capture the quick action data when app is launched with a quick action. In the AppDelegate.m or AppDelegate.mm file of the integrating project, below code needs to be placed.

#import "AppQuickActions.h"

-(void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL))completionHandler{
  [AppQuickActions performActionForQuickActionItem:shortcutItem completionHandler:completionHandler];
}

Android

No specific setup required

Summary

API

| method | Description | | --------------------------------------- | ------------------------------ | | setQuickActions | sets the quick actions | | getQuickActions | gets the current quick actions | | clearQuickActions | clears existing quick actions |

QuickActionItem

| Key | Android | iOS | Description | | ---------- | :-----: | :-: | ------------------------------------------------------------------------------- | | type | ✅ | ✅ | unique string for the quick action | | title | ✅ | ✅ | title string for the quick action | | shortTitle | ✅ | ❌ | shortTitle string which will be shown when there is space constraint in Android | | subtitle | ❌ | ✅ | subtitle string which will be shown below title in iOS | | iconName | ✅ | ✅ | iconName string | | data | ✅ | ✅ | object to have user defined values |

Usage

import

import AppQuickActions from 'react-native-app-quick-actions';

you can also import the QuickActionItem type if working with typescript for defining the Quick Action Item.

import AppQuickActions, { type QuickActionItem } from 'react-native-app-quick-actions';

setQuickActions

const quickActionItems = [
  {
    type: 'com.quickactions1',
    title: 'Quick Action 1',
    subtitle: 'Simple Quick Action',
    iconName: 'shortcut',
    data: {
      link: '/test',
    },
  },
  {
    type: 'com.quickactions2',
    title: 'Quick Action 2',
    data: {
      link: '/test2',
    },
  },
];

useEffect(() => {
  AppQuickActions.setQuickActions(quickActionItems).then((items) => {
    console.log(`---> Quick Action Items Set: ${JSON.stringify(items)}`);
  });
}, []);

getQuickActions

AppQuickActions.getQuickActions().then((items) =>
  console.log(`---> Current Quick Action Items: ${JSON.stringify(items)}`)
);

getInitialQuickAction

AppQuickActions.getInitialQuickAction().then((item) =>
  console.log(`---> App Launched with QUick Action: ${JSON.stringify(item)}`)
);

When app launched with quick action this method can be used besides listening for event. On iOS subsequent calls to this method will result in null.

clearQuickActions

AppQuickActions.clearQuickActions();

Listen for events

useEffect(() => {
  const eventEmitter = new NativeEventEmitter(AppQuickActions);
  const sub = eventEmitter.addListener(
    'onQuickActionItemPressed',
    ({ item, initial }) => {
      const { type, data } = item;
      console.log(
        `---> Quick Action Item Clicked type:${type}, data:${JSON.stringify(data)}, isInitial: ${initial}`
      );
    }
  );
  return () => sub.remove();
}, []);

Either the app is launched with a quick action or when the app is brought to foreground using a quick action, In both cases event is emitted and the initial flag is set accordingly in the callback.

Hooks

For convenience there is hook for handling quick action events.

useAppQuickActionHandler

useAppQuickActionHandler(({ item, initial }) => {
  const { type, data } = item;
  console.log(
    `---> Quick Action Item Clicked type:${type}, data:${JSON.stringify(data)}, isInitial: ${initial}`
  );
});

Icons

Android

Icons needs to be in drawables folder. For guidelines on shortcut icons you can follow this guide

iOS

Icons in iOS needs to be inside Asset Catalogue. For icon guidelines you can follow this guide

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library