tschoffelen / react-native-email-link

📭 Open an email client from React Native (for 'magic link' type functionality).
MIT License
394 stars 70 forks source link

Add a config plugin for automatic setup with Expo #93

Closed matt-oakes closed 2 years ago

matt-oakes commented 2 years ago

This PR adds an [Expo Config Plugin]() which allows the library to be configured for Expo apps without manually modifying the app.config.js file with specific confoguration. Instead, to set this up, you just need to add the plugin to the list:

{
  "name": "my app",
  "plugins": ["react-native-email-link"]
}

In the future, if the plugin is updated (for example new querys need to be listed in the info.plist) then Expo users will atuomatically get these changes without needing to manually update their app.config.js.

I have also added the required Android code to the libraries AndroidManifest.xml. This will automatically be merged into the user's AndroidManifest.xml through the Android manifest merging system. This will work for both regualr React Native and Expo users who are using custom development clients.

To test these changes you can see that the correct settings are in the geneated config by adding the libary and plugin to an Expo app and running expo config --type prebuild. You should see the LSApplicationQueriesSchemes in the outputted config without them needing to be listed in the app.config.js manually.

You can also test the manifest merging by updating the library and running ./graldew assembleDebug and looking at the merged manifest in android/app/build/intermediated/merged_manifest/debug/out/AndroidManifest.xml. It should included the required mailto query.

tschoffelen commented 2 years ago

Released to NPM as react-native-email-link@1.12.0

matt-oakes commented 2 years ago

I have updated and tested this in our app and it is working well. Thanks for the quick response!