Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expo custom config plugin #64

Open
marcfrankel opened this issue Feb 9, 2023 · 5 comments
Open

Expo custom config plugin #64

marcfrankel opened this issue Feb 9, 2023 · 5 comments

Comments

@marcfrankel
Copy link

Thought I would leave this here for anyone who needs it but this is a basic config plugin I made to get this package working with Expo.

Would love to see someone take this, polish it up a bit, and include it in the package itself. But hopefully it's useful to anyone in the future.

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

const withCustomManifest = (config) => {
    return withAndroidManifest(config, async (config) => {
        let androidManifest = config.modResults.manifest;

        androidManifest['queries'].push({
            intent: [
                {
                    action: [
                        {
                            $: {
                                'android:name': 'android.intent.action.VIEW',
                            },
                        },
                    ],
                    category: [
                        {
                            $: {
                                'android:name':
                                    'android.intent.category.DEFAULT',
                            },
                        },
                    ],
                    data: [
                        {
                            $: {
                                'android:mimeType':
                                    'vnd.android.cursor.dir/contact',
                            },
                        },
                    ],
                },
            ],
        });

        return config;
    });
};

module.exports = function withAndroidContactSelector(config) {
    return withPlugins(config, [withCustomManifest]);
};
@seanadkinson
Copy link
Contributor

Thanks @marcfrankel! Where would we actually put this file in our project in order for it to be auto-picked up and used by Expo? Would you like to create a PR to bring this in?

@marcfrankel
Copy link
Author

@seanadkinson I think more info can be found here: https://docs.expo.dev/guides/config-plugins/#importing-plugins

I could potentially open a PR to do this if that's desired, but I will caution what I wrote is extremely rough and may need to be improved past my skill level...

@eniolajayi
Copy link

@seanadkinson There's a pr for this by @iamMAHAM . It would be nice to have the package support expo

@seanadkinson
Copy link
Contributor

@eniolajayi Unfortunately I am no longer an Editor in this repo. Perhaps @giantryansaul or @kjanderson2 can direct someone to assist?

@StevenHallLtd
Copy link

Anyone looking to set this in their app.json, here's what worked for me...

{
  "expo": {
    "plugins": [
      [
        "expo-build-properties",
        {
          "android": {
            "manifestQueries": {
              "intent": [
                {
                  "action": "VIEW",
                  "category": ["DEFAULT"],
                  "data": { "mimeType": "vnd.android.cursor.dir/contact" }
                }
              ]
            }
          }
        }
      ]
    ]
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants