My recent OSS contribution to rn-email-link
24.01.2024
Using OSS libraries but missing some functionality? Try to add them yourself to give back to the community!
Lately, I had a chance to contribute to OSS a bit by adding one small addition to the react-native-email-link
library! While developing a new feature, I needed to display a custom sheet with all available email apps. Library turned out to be useful BUT was not exposing any way for the developer to have the list rendered within a custom piece of UI.
After looking into the source code, it was not hard to expand the library's feature set and I got down to work!
You can take a look at the contribution here: GitHub - react-native-email-link#130.
Get all available email clients
The thing I was missing, was the get-me-all-avaiable-email-clients-there-are-on-the-device-like method!
Given this requirement, I quickly added a patch with a missing method (thank you patch-package
!) and applied it to the library.
const clients = await getEmailClients();
// clients -> {
// iOSAppName: "gmail", // iOS only
// prefix: "gmail://",
// title: "GMail",
// androidPackagename: "com.google.android.gm", // Android only
// id: "gmail",
// }[]
Opening a specific app's email composer
Another thing I was missing was the ability to open a specific app's email composer window. Library was exposing such a method but it was prompting users to choose the specific app with a native pop up.
What I wanted though, was to just call it with some app identifier and omit this pop up. Desired outcome:
import { openComposer } from "react-native-email-link";
openComposer({app: 'gmail'}); // now, the app attribute is taken into consideration!
After some work, I patched it, tested and decided to submit a PR with my changes to the library itself in hope that it could help other devs out there!
You can take a look at the code here: PR #130
Daniel