react-native-quick-actions icon indicating copy to clipboard operation
react-native-quick-actions copied to clipboard

Added static shortcuts android

Open Peretz30 opened this issue 5 years ago • 2 comments

Resolves #98 To create static shortcuts, follow Android Docs But! I didn't figure out how to make it work with cold start. It works when app is in foreground, but if you close app and try to start with quick action, when callback is not called. I think its connected with MainActivity and it's Intent and could be fixed with right config in shortcuts.xml. But I can't succeed with that. My shortcuts.xml looks like this:

<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
  <shortcut
    android:shortcutId="newBusinessTrip"
    android:shortcutShortLabel="@string/newBusinessTrip">
    <intent
    android:action="android.intent.action.MAIN"
      android:targetPackage="com.example.myapplication"
      android:targetClass="com.example.myapplication.MainActivity"
    />
    <intent
      android:action="ACTION_SHORTCUT_STATIC"
      android:targetPackage="com.example.myapplication"
      android:targetClass="com.example.myapplication.MainActivity"
      >
      <extra
            android:name="SHORTCUT_ITEM_TYPE"
            android:value="newBusinessTrip" />
            <extra
            android:name="SHORTCUT_ITEM_TITLE"
            android:value="test" />
      </intent>
  </shortcut>
  <!-- Specify more shortcuts here. -->
</shortcuts>

Your package name instead com.example.myapplication

Peretz30 avatar May 13 '20 08:05 Peretz30

@Peretz30 any updates?

artklen avatar Oct 14 '21 08:10 artklen

@Peretz30 I think this doesn't work on last RN 0.71 I use your fork and code QuickActions.popInitialAction().then(onAction).catch(console.error) onAction not called.

anatooly avatar Mar 13 '23 11:03 anatooly