Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Mobile Protect builds are served from the following git repository: <httpshttps://mobile-protect-repos.securetheorem.com/mobileprotect-ios.>

Access via SPM and CocoaPods, or Clone the Repo

...

Code Block
languagesh
git clone <httpshttps://any:{REPO_API_KEY}@mobile-protect-repos.securetheorem.com/mobileprotect-ios>ios

You can avoid the need for directly referencing the Repo API Key by adding it to your environment's .netrc file. Add the following to ~/.netrc (create the file if it doesn't already exist):

...

Enter the following URL in Xcode, FileAdd Package Dependencies…Enter Package URL:

Code Block
<httpshttps://spm:{REPO_API_KEY}@mobile-protect-repos.securetheorem.com/mobileprotect-ios>ios

Replace {REPO_API_KEY} with your real Repo API Key. If the Repo API Key has already been added to your environment's .netrc file, spm:{REPO_API_KEY}@ can be omitted from the URL.

...

Android: Add Mobile Protect SDK

1

...

. Add the Mobile Protect Maven Repository

The Mobile Protect for Android SDK is hosted on a private Maven repository. To be able to fetch the dependency, you must first register the dependency within your Gradle manifest.

You will need to add our repository to the plugin repositories, and as of time of writing, Cordova doesn’t support editing settings.gradle, so you need to declare it in your settingsan init.gradle file in $GRADLE_HOME or passing the init file via cli cordova build android -- --gradleArg="--init-script init.gradle":

Code Block
languagegroovy
pluginManagementsettingsEvaluated { settings ->
    repositoriessettings.pluginManagement {
         mavenCentral()repositories {
            gradlePluginPortalmavenCentral()
        google    gradlePluginPortal() 
            google()
   // Mobile Protect Maven Repository     maven {
  maven {             credentials {
                    // Leave the username as "MAVEN"
                    username "MAVEN"
                    password "$MOBILEPROTECTINSERT_REPOYOUR_API_KEY"
                }
                url "<httpshttps://mobile-protect-repos.securetheorem.com/mobileprotect-android>"android"
            }
        }
    }
}

Our plugin will then download its project dependencies so you will also need to add our repository to your project’s build.gradle file:

Code Block
languagegroovy
allprojects {
    repositories {
        mavenCentral()
        google()
        
        // Mobile Protect Maven Repository
        maven {
            credentials {
                // Leave the username as "MAVEN"
                username "MAVEN"
                password "$MOBILEPROTECTINSERT_REPOYOUR_API_KEY"
            }
            url "<httpshttps://mobile-protect-repos.securetheorem.com/mobileprotect-android>android"
        }
    }
}

If you use Cordova’s default repositories.gradle setup, you will need to add our repository to all repositories.gradle files. There are usually three of these:

  • platforms/android/repositories.gradle

  • platforms/android/app/repositories.gradle

  • platforms/android/cordovaLib/repositories.gradle

Code Block
ext.repos = {
    google()
    mavenCentral()
    maven {
      credentials {
          //Leave the username as "MAVEN"
          username "MAVEN"
          password "INSERT_YOUR_KEY"
      }
      url "https://mobile-protect-repos.securetheorem.com/mobileprotect-android"
  }
}

Note: If you use settings for dependency management (for ex. if you see the error “Build was configured to prefer settings repositories over project repositories”) the Data Theorem repository will need to be added in settings.gradle under dependencyResolutionManagement->repositories.

...

Note: If you encounter duplication issues because you have both TrustKit and MobileProtect, you can use the com.dtplugin.mobileprotect-notrustkit artefact and keep TrustKit as is.

3

...

Now you're ready to initialize the SDK. Within your application's main Application class, preferably in the onCreate() method, add the following code:

...

languagejava

...

.

...

Android: Mobile Protect Configuration

Add the Mobile Protect Config

In the Android project, create the xml directory (/app/src/main/res/xml) if it does not exist. Then, copy the mobileprotect.xml config file into the xml resources folder. mobileprotect.xml can be downloaded from our portal.

The AUTH_TOKEN key contained in the configuration file is not sensitive. The key is only used to identify the data sent by Mobile Protect to the backend, but cannot be used to pull any data from the app nor the backend. It is safe to commit and have the token in the .apk as it is used as an identifier, similar to Google's Firebase: https://firebase.google.com/docs/projects/api-keys .Congratulations! The

4. Initialize Mobile Protect

...

Now you're ready to initialize the SDK. Within your application's main Application class, preferably in the onCreate() method, add the following code:

Code Block
languagejava
MobileProtect.init(this, R.xml.mobileprotect);

If you don’t have an Application object, you need to create one and register it in AndroidManifest.xml

5. Optional: configuration for static obfuscation

You can enable Mobile Protect obfuscation in the project build.gradle with:

Code Block
MobileProtectPluginConfiguration { 
    enableObfuscation = true
}

If static obfuscation is enabled for a Cordova project then the following proguard rules must be added to your proguard-rules.pro file in order to prevent plugins from breaking:

Code Block
-dontwarn kotlin.reflect.jvm.KCallablesJvm
-keep class org.apache.cordova.** {*;}
-keep class * extends org.apache.cordova.CordovaPlugin {*;}

If your project does not contain a proguard-rules.pro file you can add one in platforms/android/app/build.gradle

Code Block
android {
    //...
    buildTypes {
        release {
            //...
            proguardFiles("proguard-rules.pro")
        }
    }
}

...

Other Installation Guides

...