2

I am trying to implement quick actions in my react native app.

lets say:

There are 3 shortcut items. When long pressed in app icon, it will show these menus but when tapped those, it just opens app, but deep linking is not working.

But whenever I enter those urls in safari, deep linking works. (app does open and navigate to mentioned screen)

QuickActions.setShortcutItems([
            {
                type: "Camera", 
                title: "Camera", 
                subtitle: "",
                icon: "Camera", 
                userInfo: {
                    url: "app://camera"
                }
            },
            {
                type: "Profile", 
                title: "Profile", 
                subtitle: "",
                icon: "Contact", 
                userInfo: {
                    url: "app://profile"
                }
            },
            {
                type: "Change Password", 
                title: "Change Password", 
                subtitle: "",
                icon: "Cloud", 
                userInfo: {
                    url: "app://change"
                }
            }

        ]);

I am using:

"react-native-quick-actions": "^0.3.13",

"react": "16.8.6",

"react-native": "0.60.5",

Shu.T
  • 439
  • 1
  • 6
  • 12

1 Answers1

0

You have to provide a function for that :

import { DeviceEventEmitter, Linking } from 'react-native';

const navigateToShortcutItem = (shortcutItem) => {
  if (shortcutItem) {
    Linking.openURL(`app://${shortcutItem.userInfo.url}`);
  }
};

DeviceEventEmitter.addListener('quickActionShortcut', navigateToShortcutItem);
Timcu Alexei
  • 121
  • 5