DEV Community

putu eka mulyana
putu eka mulyana

Posted on

1

Custom queries AndroidManifest Pada Expo

Pendahuluan

Kenapa saya ingin membuat custom queries pada android AndroidManifest? saat membuat fitur share ke instagram stories saya mengalami kendala saat user klik share yang terbuka bukan instagram stories tapi aplikasi lain.

setelah melempar pertanyaan ke forum. ada yang menyarankan menambahkan custom queries seperti pada AndroidManifest.xml.

  <queries>
      <!-- Specific apps you share to -->
      <package android:name="com.instagram.android" />
      <intent>
        <action android:name="android.intent.action.SEND"/>
      </intent>
    </queries>
Enter fullscreen mode Exit fullscreen mode

masalahnya saat build menggunakan server expo code di atas tidak ikut dibuild karena file android yang ada di local computer tidak ikut di submit ke dalam server expo.

Solusi

Solusi yang saya temukan adalah dengan menambahakan code expo config plugins agar saat di build di server expo queries ikut tergenerate.

const { withAndroidManifest } = require('@expo/config-plugins');

const withAndroidQueries = config => {
  return withAndroidManifest(config, config => {
    config.modResults.manifest.queries = [
      {
        package: [
          {
            $: { 'android:name': 'com.instagram.android' },
          },
        ],
        intent: [
          {
            action: [{ $: { 'android:name': 'android.intent.action.SEND' } }],
          },
        ],
      },
    ];

    return config;
  });
};

module.exports = withAndroidQueries;
Enter fullscreen mode Exit fullscreen mode

jika ingin mengecek apakah file queries tergenerate di dalam AndroidManifest.xml coba run :

npx expo prebuild
Enter fullscreen mode Exit fullscreen mode

lalu cek di dalam file AndroidManifest.xml apakah sudah ada code seperti dibawah :

  <queries>
      <!-- Specific apps you share to -->
      <package android:name="com.instagram.android" />
      <intent>
        <action android:name="android.intent.action.SEND"/>
      </intent>
    </queries>
Enter fullscreen mode Exit fullscreen mode

Penutup

Jika kamu memiliki saran atau cara yang lain feel free to comment

Sentry blog image

The Visual Studio App Center’s retiring

But sadly….you’re not. See how to make the switch to Sentry for all your crash reporting needs.

Read more

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

AWS GenAI LIVE!

GenAI LIVE! is a dynamic live-streamed show exploring how AWS and our partners are helping organizations unlock real value with generative AI.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️