Installation

Distribution

Malwarelytics for React Native is distributed as an NPM package. The private Maven repository for the Android native library and the private CocoaPods repository for the iOS native library is used under the hood.

Platform Support

Malwarelytics for React Native supports iOS 13.4 and Android 6.0 (SDK version 23) and above. React Native 0.74 and above is recommended for your application.

Configure Wultra’s Artifactory

Personalized Configuration Required.
In order to use Malwarelytics for React Native, you need a custom configuration and access credentials for both the service and the artifact repository. Contact your sales representative or technical consultant to obtain the necessary prerequisites.

Adding Maven Repository

Add a new Maven repository pointing to Wultra Artifactory to your main application’s gradle file located at android/build.gradle:

allProjects {
    repositories {
        maven {
            url 'https://wultra.jfrog.io/artifactory/malwarelytics-android/'
            credentials {
                username '[email protected]'
                password 'some-password'
            }
        }
    }
}

In the same file, look for minSdkVersion and make sure that it’s higher or equal to 23.

If you don’t want to expose your credentials in the gradle file, then use the script to load the credentials from local.properties. For example:

// Load Artifactory credentials from the 'local.properties' file. It's expected that credentials
// are set in 'wultraArtifactory_username' or 'wultraArtifactory_password' properties.
def loadArtifactoryCredentials(name) {
    def propName = 'wultraArtifactory_' + name
    // Try to iterate over all possible local.properties files
    def propFiles = [
        project.rootProject.file('local.properties'),
        project.file('local.properties')
    ]
    for (file in propFiles) {
        if (file.canRead()) {
            def props = new Properties()
            props.load(file.newDataInputStream())
            def value = props[propName]
            if (value != null) {
                return value
            }
        }
    }
    logger.error('Failed to resolve required property: ' + propName)
    return null
}

allProjects {
    repositories {
        maven {
            url 'https://wultra.jfrog.io/artifactory/malwarelytics-android/'
            credentials {
                username loadArtifactoryCredentials('username') // wultraArtifactory_username
                password loadArtifactoryCredentials('password') // wultraArtifactory_password
            }
        }
    }
}

Configure CocoaPods

Create (or append to if already exists) a ~/.netrc file in your home directory (~) with your credentials to Wultra Artifactory.

machine wultra.jfrog.io
      login [email protected]
      password some-password

Adding Module Dependency

Use your favorite dependency manager to add the dependency:

# npm
npm i react-native-malwarelytics --save
# yarn
yarn add react-native-malwarelytics

Use Malwarelytics in your js/ts files

The Malwarelytics class provides a static property that contains a singleton instance of the class:

import { Malwarelytics } from 'react-native-malwarelytics';

const service = Malwarelytics.sharedInstance;
Last updated on Oct 25, 2024 (14:24) View product
Search

develop

Malwarelytics for React Native