Installation
Distribution
Malwarelytics for React Native is distributed as a 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 11 and Android 5.1 (SDK version 22) and above. The React Native 0.71 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'
}
}
}
}
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 '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
}
def artifactoryUsername = loadArtifactoryCredentials('username') // wultraArtifactory_username
def artifactoryPassword = 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 singleton instance of the class:
import { Malwarelytics } from 'react-native-malwarelytics';
const service = Malwarelytics.sharedInstance;