expo / config-plugins

Out-of-tree Expo config plugins for packages that haven't adopted the config plugin system yet.
428 stars 91 forks source link

feat(react-native-razorpay): add config plugin for UPI Intent support on iOS #119

Closed gerzonc closed 1 year ago

gerzonc commented 1 year ago

Why

Related issue: #379

But basically, by following React Native Razorpay docs we can see that in order to use the UPI Intent on iOS we must add the apps URL scheme's to LSApplicationQueriesSchemes.

How

We must pass values to the LSApplicationQueriesSchemes on Info.plist, more specifically, an array of values, to tell which apps our app is going to communicate with (e.g. tez, phonepe and paytmmp).

Test Plan

  1. Follow the instructions to install the lib on your app.
  2. Add the following to your plugins attribute on your app.json (or app.config.ts):
    plugins: [
    [
      "react-native-razorpay",
      { paymentApps: ["tez", "phonepe", "paytmmp"] },
    ],
    ]
EvanBacon commented 1 year ago

Alternatively, could just document that the user must add schemes to the Info.plist directly:

{
  "expo": {
    "ios": {
      "infoPlist": {
        "LSApplicationQueriesSchemes": [...]
      }
    }
  }
}

and avoid the config plugin altogether. Another possible solution could be something simple like this:

module.exports = function (config, schemes) => {
  if (!config.ios) config.ios = {}
  if (!config.ios.infoPlist) config.ios.infoPlist = {}
  if (!Array.isArray(config.ios.infoPlist.LSApplicationQueriesSchemes)) {
    config.ios.infoPlist.LSApplicationQueriesSchemes = []
  }
  config.ios.infoPlist.LSApplicationQueriesSchemes = [...(new Set([
    ...config.ios.infoPlist.LSApplicationQueriesSchemes,
    ...schemes
  ])];
}
gerzonc commented 1 year ago

Alternatively, could just document that the user must add schemes to the Info.plist directly:

{
  "expo": {
    "ios": {
      "infoPlist": {
        "LSApplicationQueriesSchemes": [...]
      }
    }
  }
}

and avoid the config plugin altogether. Another possible solution could be something simple like this:

module.exports = function (config, schemes) => {
  if (!config.ios) config.ios = {}
  if (!config.ios.infoPlist) config.ios.infoPlist = {}
  if (!Array.isArray(config.ios.infoPlist.LSApplicationQueriesSchemes)) {
    config.ios.infoPlist.LSApplicationQueriesSchemes = []
  }
  config.ios.infoPlist.LSApplicationQueriesSchemes = [...(new Set([
    ...config.ios.infoPlist.LSApplicationQueriesSchemes,
    ...schemes
  ])];
}

Ooh, didn't know we could modify Info.plist directly from app.json 😲 I believe there is no need for this config plugin then!