jordanbyron / react-native-quick-actions

A react-native interface for Touch 3D home screen quick actions
MIT License
1.06k stars 93 forks source link

Added static shortcuts android #99

Open Peretz30 opened 4 years ago

Peretz30 commented 4 years ago

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

artklen commented 2 years ago

@Peretz30 any updates?

anatooly commented 1 year ago

@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.