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 Compatibility #11

Open
josefelbez opened this issue Mar 14, 2024 · 10 comments
Open

Expo Compatibility #11

josefelbez opened this issue Mar 14, 2024 · 10 comments

Comments

@josefelbez
Copy link

Hi, any plans to provide expo compatibility out of the box?

Since expo is becoming the to go option nowadays would be good to have something like a config plugin to use with expo

Ref: https://docs.expo.dev/config-plugins/introduction/

Also, are you open source friendly? As could I assign it to myself and open a pr for that?

@0mitch
Copy link

0mitch commented Mar 20, 2024

Would also be very interested in this as I'm trying to integrate SumSub into an Expo app as well.

@jvfalco1
Copy link

@0mitch did you managed to do it? is it possible?

@ricp
Copy link

ricp commented Aug 21, 2024

I am also interested in the solution, if there is one.

@akeeee
Copy link

akeeee commented Aug 22, 2024

It can be done, but it might be a little tricky.

For web, you can follow this guide:
https://docs.sumsub.com/docs/get-started-with-web-sdk#react-integration

For native, you can follow this guide:
https://docs.sumsub.com/docs/react-native-module. You’ll need to use expo-build-properties to configure the dependencies required by Sumsub.
expo-build-properties documentation.

For usage of the camera, microphone, photo library, and geolocation, you can use plugins like expo-camera
Expo Camera documentation.

Here’s some example:

{
  "plugins": [
    [
      "expo-build-properties",
      {
        "android": {
          "extraMavenRepos": [
            {
              "url": "https://maven.sumsub.com/repository/maven-public/"
            }
          ]
        },
        "ios": {
          "extraPods": [
            {
              "source": "https://github.com/SumSubstance/Specs.git",
              "name": "IdensicMobileSDK",
              "version": "1.32.0"
            }
          ]
        }
      }
    ],
    [
      "expo-camera",
      {
        "cameraPermission": "Allow apps to access your camera",
        "microphonePermission": "Allow apps to access your microphone",
        "recordAudioAndroid": true
      }
    ]
  ]
}

@ricp
Copy link

ricp commented Aug 22, 2024

Thanks! I will try this 👍

@felipecornejo1
Copy link

felipecornejo1 commented Aug 22, 2024

It can be done, but it might be a little tricky.

For web, you can follow this guide: https://docs.sumsub.com/docs/get-started-with-web-sdk#react-integration

For native, you can follow this guide: https://docs.sumsub.com/docs/react-native-module. You’ll need to use expo-build-properties to configure the dependencies required by Sumsub. expo-build-properties documentation.

For usage of the camera, microphone, photo library, and geolocation, you can use plugins like expo-camera Expo Camera documentation.

Here’s some example:

{
  "plugins": [
    [
      "expo-build-properties",
      {
        "android": {
          "extraMavenRepos": [
            {
              "url": "https://maven.sumsub.com/repository/maven-public/"
            }
          ]
        },
        "ios": {
          "extraPods": [
            {
              "source": "https://github.com/SumSubstance/Specs.git",
              "name": "IdensicMobileSDK",
              "version": "1.32.0"
            }
          ]
        }
      }
    ],
    [
      "expo-camera",
      {
        "cameraPermission": "Allow apps to access your camera",
        "microphonePermission": "Allow apps to access your microphone",
        "recordAudioAndroid": true
      }
    ]
  ]
}

I tried all of this, but I'm getting this error when trying to build with expo run:android

     Duplicate class org.bouncycastle.x509.X509V2CRLGenerator$ExtCRLException found in modules jetified-bcprov-jdk15to18-1.70 (org.bouncycastle:bcprov-jdk15to18:1.70) and jetified-bcprov-jdk18on-1.71 (org.bouncycastle:bcprov-jdk18on:1.71)
     Duplicate class org.bouncycastle.x509.X509V3CertificateGenerator found in modules jetified-bcprov-jdk15to18-1.70 (org.bouncycastle:bcprov-jdk15to18:1.70) and jetified-bcprov-jdk18on-1.71 (org.bouncycastle:bcprov-jdk18on:1.71)
     Duplicate class org.bouncycastle.x509.extension.AuthorityKeyIdentifierStructure found in modules jetified-bcprov-jdk15to18-1.70 (org.bouncycastle:bcprov-jdk15to18:1.70) and jetified-bcprov-jdk18on-1.71 (org.bouncycastle:bcprov-jdk18on:1.71)
     Duplicate class org.bouncycastle.x509.extension.X509ExtensionUtil found in modules jetified-bcprov-jdk15to18-1.70 (org.bouncycastle:bcprov-jdk15to18:1.70) and jetified-bcprov-jdk18on-1.71 (org.bouncycastle:bcprov-jdk18on:1.71)
     Duplicate class org.bouncycastle.x509.util.LDAPStoreHelper found in modules jetified-bcprov-jdk15to18-1.70 (org.bouncycastle:bcprov-jdk15to18:1.70) and jetified-bcprov-jdk18on-1.71 (org.bouncycastle:bcprov-jdk18on:1.71)
     Duplicate class org.bouncycastle.x509.util.StreamParser found in modules jetified-bcprov-jdk15to18-1.70 (org.bouncycastle:bcprov-jdk15to18:1.70) and jetified-bcprov-jdk18on-1.71 (org.bouncycastle:bcprov-jdk18on:1.71)
     Duplicate class org.bouncycastle.x509.util.StreamParsingException found in modules jetified-bcprov-jdk15to18-1.70 (org.bouncycastle:bcprov-jdk15to18:1.70) and jetified-bcprov-jdk18on-1.71 (org.bouncycastle:bcprov-jdk18on:1.71)

     Go to the documentation to learn how to <a href="d.android.com/r/tools/classpath-sync-errors">Fix dependency resolution errors</a>.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to https://docs.gradle.org/8.3/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.

BUILD FAILED in 50s
783 actionable tasks: 324 executed, 443 from cache, 16 up-to-date
The Daemon will expire after the build after running out of JVM Metaspace.
The project memory settings are likely not configured or are configured to an insufficient value.
The daemon will restart for the next build, which may increase subsequent build times.
These settings can be adjusted by setting 'org.gradle.jvmargs' in 'gradle.properties'.
The currently configured max heap space is '2 GiB' and the configured max metaspace is '512 MiB'.
For more information on how to set these values, please refer to https://docs.gradle.org/8.3/userguide/build_environment.html#sec:configuring_jvm_memory in the Gradle documentation.
To disable this warning, set 'org.gradle.daemon.performance.disable-logging=true'.
Daemon will be stopped at the end of the build after running out of JVM Metaspace

the step it fails at is :app:checkDebugDuplicateClasses

anyone else went through the same?

@jvfalco1
Copy link

jvfalco1 commented Sep 9, 2024

Anyone figured out something about this topic?

@felipecornejo1
Copy link

Anyone figured out something about this topic?

We ended up redirecting to a web app and then back to mobile app because we couldn't solve this quickly. We're waiting for some solution so we can migrate to the mobile SDK

@akeeee
Copy link

akeeee commented Nov 20, 2024

Update for Expo SDK 52.

For Expo SDK 52, I configured the following in app.json, so you don't need to configure the permissions manually:

 "plugins": [
       [
        "expo-build-properties",
        {
          "android": {
            "usesCleartextTraffic": true,
            "extraMavenRepos": [
              {
                "url": "https://maven.sumsub.com/repository/maven-public/"
              }
            ]
          },
          "ios": {
            "extraPods": [
              {
                "source": "https://github.com/SumSubstance/Specs.git",
                "name": "IdensicMobileSDK",
                "version": "1.33.1"
              }
            ]
          }
        }
      ],
]

Hope this helps!

@antoniogoulao
Copy link

I created this expo-plugin

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

/**
 * Adds the Maven repository URL to the `allprojects.repositories` section in `android/build.gradle`.
 */
const addMavenRepository = (buildGradle) => {
  const mavenSnippet = '        maven { url "https://maven.sumsub.com/repository/maven-public/" }';

  // Check if the snippet is already present to avoid duplication
  if (buildGradle.includes(mavenSnippet)) {
    console.log('Maven repository already exists in build.gradle.');
    return buildGradle;
  }

  // Split build.gradle content into lines for line-by-line manipulation
  const lines = buildGradle.split('\n');

  // Locate the start of the `allprojects {` block
  const allProjectsIndex = lines.findIndex((line) => line.includes('allprojects {'));
  if (allProjectsIndex === -1) {
    console.warn('Could not find "allprojects" section in build.gradle.');
    return buildGradle;
  }

  // Locate the `repositories {` block within `allprojects {`
  const repositoriesIndex = lines.findIndex(
    (line, idx) => idx > allProjectsIndex && line.includes('repositories {'),
  );
  if (repositoriesIndex === -1) {
    console.warn('Could not find "repositories" block inside "allprojects".');
    return buildGradle;
  }

  // Find the closing brace of the `repositories {` block
  const repositoriesEndIndex = lines.findIndex(
    (line, idx) => idx > repositoriesIndex && line.trim() === '}',
  );
  if (repositoriesEndIndex === -1) {
    console.warn('Could not find the end of the "repositories" block.');
    return buildGradle;
  }

  // Insert the Maven snippet just before the closing brace of `repositories {`
  lines.splice(repositoriesEndIndex, 0, mavenSnippet);

  // Join the lines back into a single string
  return lines.join('\n');
};

const withSumsubAndroidMavenDependency = (config) => {
  return withProjectBuildGradle(config, (config) => {
    config.modResults.contents = addMavenRepository(config.modResults.contents);
    return config;
  });
};

module.exports = withSumsubAndroidMavenDependency;

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

7 participants