Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

The Mobile Protect SDK has a dedicated integration for iOS and Android apps built using Flutter. This document will take you through the steps to integrate the SDK into your build system. For other guides, check out Mobile Protect Installation Guides

Preface

This will involve some steps on the Flutter side as well as some steps on both iOS and Android.

Flutter Integration

Step 1

Download the SDK from the Mobile Protect in the Portal.

Step 2

Copy the flutter_mobile_protect directory to the root of the Flutter project.

Step 3

Add flutter_mobile_protect as a dependency in your pubspec.yaml file:

$ flutter pub add flutter_mobile_protect --path flutter_mobile_protect/

The project’s pubspec.yaml should then contain the following entry:

dependencies:
   flutter_mobile_protect:
     path: flutter_mobile_protect

Step 4

In your main.dart file

  1. Import the Mobile Protect for Flutter library:
    import 'package:flutter_mobile_protect/flutter_mobile_protect.dart';

  2. Add the following initialiser method:

    Future<void> initMobileProtect() async {
      try {
        await FlutterMobileProtect.init;
      } on PlatformException {
        print("Failed to initialize");
      }
    }
  3. Call initMobileProtect() when initialising your main App widget.

Android Integration

Step 1: Add the Mobile Protect Gradle Plugin

Declare dependencies within your project’s build.gradle as follows:

buildscript {
    dependencies {
        classpath files('../flutter_mobile_protect/android/mobileprotect/gradle{VERSION}+_plugin/mobile-protect-gradle-plugin.jar')
        classpath 'org.aspectj:aspectjtools:1.9.4'
    }
}

Note: replace {VERSION} with one of the provided versions in the SDK that matches the version of Gradle your project is using.

Step 2: Activate the Plugin

Activate the plugin in your App module's build.gradle file, by adding the following statement after the apply plugin: 'com.android.application' statement.

apply plugin: 'com.dtplugin.mobileprotect'

Step 3: Add the Mobile Protect configuration

In the Android project, create the xml directory (flutter_app/android/app/src/main/res/xml) if it does not exist. Then, copy the mobileprotect.xml config file into the xml resources folder.

iOS Integration

In the iOS project copy the MobileProtect.plist config file into the Flutter project's Xcode project, place it in the project root. See Add Existing Files and Folders to a Project for instructions.

Results

Please visit https://www.securetheorem.com/mobile/protect to see the list of your apps and the state of protection, along with the individual protection item details.

  • No labels