Documentation

Go to Portal Website

SDK Integration - Library Mode

Overview

Library Mode lets Enterprise teams embed MobileDefender directly in app source code. AppTego generates a custom Android AAR and iOS framework archive for your application identifier, then your team adds the library to the app, initializes it, enables controls from code, and owns the final build, signing, QA, and distribution process.

Most teams should start with Standard Mode. Use Library Mode only when your app needs source-level callbacks, runtime control decisions, or a release process where your own build pipeline must produce the final signed binary.

Before You Choose Library Mode

ConfirmWhy it matters
Enterprise accessCustom Library / BYOA generation is Enterprise-only.
Application identifierEach custom library is generated for an Android package name or iOS bundle ID.
Source-code ownershipMobile engineers must add, initialize, test, and maintain the SDK integration.
Runtime control modelThe custom library contains tenant bootstrap data; your app enables detection and prevention controls through the SDK API.
Release processYour pipeline is responsible for final app compilation, signing, QA, and distribution.
Obfuscation expectationsThe Standard Mode post-build obfuscation workflow does not apply to the final app in Library Mode.
Testing coverageDetection callbacks and prevention behavior should be validated on physical devices before release.

Generate A Custom Library

  1. Open Custom Library in the portal.
  2. Enter the app identifier the library will be used with, such as com.company.app.
  3. Save the identifier to queue Android and iOS library builds.
  4. Wait until each platform download is available.
  5. Download the platform artifact and store it in your controlled dependency or artifact process.

Downloads use short-lived URLs. If a download URL expires, request the download again from the Custom Library page.

Application identifiers must use reverse-DNS notation with at least three segments. Placeholder or reserved namespaces such as com.example.*, com.test.*, org.example.*, com.android.*, android.*, java.*, and javax.* are rejected.

Android SDK

Installation

Download mobiledefender.aar, add it to a controlled location in your Android project, and declare it as a dependency:

dependencies {
    implementation files('libs/mobiledefender.aar')
    implementation 'com.google.android.play:integrity:1.4.0'
    implementation 'androidx.security:security-crypto:1.1.0-alpha06'
}

Initialization

Initialize MobileDefender once, before protected workflows need it:

import android.app.Application;

import com.example.mobiledefender.MobileDefender;

public class MyApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        MobileDefender.initMobileDefender(this);
    }
}

Detection Controls

Detection controls take an enabled flag and a callback. The callback receives the native control name and message when that control reports an event.

import android.util.Log;

MobileDefender.DetectionCallback callback = new MobileDefender.DetectionCallback() {
    @Override
    public void onDetection(String controlName, String message) {
        Log.w("Security", controlName + ": " + message);
    }
};

MobileDefender.rootDetection(true, callback);
MobileDefender.overlayDetection(true, callback);
MobileDefender.hookDetection(true, callback);
MobileDefender.emulatorDetection(true, callback);
MobileDefender.debuggableDetection(true, callback);
MobileDefender.usbConnectionDetection(true, callback);
MobileDefender.screenRecordingDetection(true, callback);
MobileDefender.screenMirroringDetection(true, callback);
MobileDefender.vpnDetection(true, callback);
MobileDefender.proxyUsageDetection(true, callback);
MobileDefender.locationSpoofingDetection(true, callback);
MobileDefender.timeTamperingDetection(true, callback);
MobileDefender.thirdPartyKeyboardDetection(true, callback);
MobileDefender.accessibilityServiceDetection(true, callback);
MobileDefender.unknownSourcesDetection(true, callback);
MobileDefender.virtualAppDetection(true, callback);
MobileDefender.appCloningDetection(true, callback);
MobileDefender.screenCaptureDetection(true, callback);
MobileDefender.developerOptionsDetection(true, callback);
MobileDefender.deviceLockDetection(true, callback);

Pass false to disable a previously enabled control:

MobileDefender.rootDetection(false, null);

Integrity And Pinning

Integrity checks use the same callback signature. Play Integrity, app tamper, and certificate pinning also expose typed overloads for control-specific input.

MobileDefender.playIntegrityCheck(true, callback);
MobileDefender.playIntegrityCheck(true, "123456789012", callback);

MobileDefender.appTamperCheck(true, callback);
MobileDefender.appTamperCheck(true, resourceHash, signingCertHash, callback);

MobileDefender.CertificatePin apiPin = new MobileDefender.CertificatePin(
        "a1b2c3...",
        "sha256",
        new String[] {"api.example.com"},
        false
);
MobileDefender.certificatePinning(true, new MobileDefender.CertificatePin[] {apiPin}, callback);

Prevention Controls

Prevention controls do not emit callbacks. They take only the enabled flag.

MobileDefender.androidScreenCaptureProtection(true);
MobileDefender.debuggablePrevention(true);
MobileDefender.clipboardProtectionPrevention(true);
MobileDefender.taskSwitcherBlurPrevention(true);
MobileDefender.storagePermissionHardeningPrevention(true);
MobileDefender.tls13OnlyPrevention(true);
MobileDefender.autofillSuggestionPrevention(true);
MobileDefender.webViewHardeningPrevention(true);

Use markSensitive(View) with sensitive inputs when autofill and keyboard suggestion hardening should apply to a specific view:

MobileDefender.markSensitive(passwordField);

Overlay Detection Touch Events

For overlay / tapjacking detection, forward Activity touch events:

@Override
public boolean dispatchTouchEvent(MotionEvent event) {
    MobileDefender.handleTouchEvent(event);
    return super.dispatchTouchEvent(event);
}

Cleanup

MobileDefender.cleanup() releases SDK resources. Call it only when your process or test harness is intentionally finished with MobileDefender, not after every Activity destroy.

MobileDefender.cleanup();

Requirements

RequirementValue
Minimum SDK26 (Android 8.0)
Target SDK used by the SDK build36
Java compatibility17
Native ABIs in the library buildarmeabi-v7a, arm64-v8a, x86, x86_64

iOS SDK

Installation

  1. Download the iOS library archive from Custom Library. The current library artifact is packaged as MobileDefender.xcframework.zip and contains MobileDefender.framework.
  2. Extract the archive.
  3. Drag MobileDefender.framework into your Xcode project.
  4. In Frameworks, Libraries, and Embedded Content, set the framework to Embed & Sign.

Initialization

#import <MobileDefender/MobileDefenderLibrary.h>

- (BOOL)application:(UIApplication *)application
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    UIViewController *rootVC = self.window.rootViewController;
    if (rootVC) {
        [MobileDefenderLibrary initialize:rootVC];
    }

    return YES;
}

Detection Controls

MDDetectionCallback callback = ^(NSString *controlName, NSString *message) {
    NSLog(@"Security event: %@ - %@", controlName, message);
};

[MobileDefenderLibrary jailbreakDetection:YES callback:callback];
[MobileDefenderLibrary emulatorDetection:YES callback:callback];
[MobileDefenderLibrary debuggerDetection:YES callback:callback];
[MobileDefenderLibrary hookDetection:YES callback:callback];
[MobileDefenderLibrary screenCaptureDetection:YES callback:callback];
[MobileDefenderLibrary screenMirroringDetection:YES callback:callback];
[MobileDefenderLibrary deviceLockDetection:YES callback:callback];
[MobileDefenderLibrary developerOptionsDetection:YES callback:callback];
[MobileDefenderLibrary unknownSourcesDetection:YES callback:callback];
[MobileDefenderLibrary debuggableDetection:YES callback:callback];
[MobileDefenderLibrary memoryTamperDetection:YES callback:callback];
[MobileDefenderLibrary vpnDetection:YES callback:callback];
[MobileDefenderLibrary proxyUsageDetection:YES callback:callback];
[MobileDefenderLibrary timeTamperingDetection:YES callback:callback];
[MobileDefenderLibrary locationSpoofingDetection:YES callback:callback];
[MobileDefenderLibrary thirdPartyKeyboardDetection:YES callback:callback];
[MobileDefenderLibrary appTamperCheck:YES callback:callback];
[MobileDefenderLibrary appAttestCheck:YES callback:callback];
[MobileDefenderLibrary certificatePinning:YES callback:callback];

Pass NO with a nil callback to disable a detection control:

[MobileDefenderLibrary jailbreakDetection:NO callback:nil];

Generic Detection Configuration

Use the generic API when the host app needs runtime action/message fields or control-specific data such as certificate pinning input. The control name must match one of the class-name values returned by availableDetectionControls.

[MobileDefenderLibrary setDetectionControl:@"CertificatePinning"
                                   enabled:YES
                             configuration:@{
                                 @"action": @"log",
                                 @"message": @"Certificate pinning failed",
                                 @"certificates": @[
                                     @{
                                         @"thumbprint": @"a1b2c3...",
                                         @"algorithm": @"SHA-256",
                                         @"domains": @[@"api.example.com"],
                                         @"isca": @NO
                                     }
                                 ]
                             }
                                  callback:callback];

Prevention Controls

[MobileDefenderLibrary screenshotPrevention:YES];
[MobileDefenderLibrary screenRecordingPrevention:YES];
[MobileDefenderLibrary debuggablePrevention:YES];
[MobileDefenderLibrary clipboardProtectionPrevention:YES];
[MobileDefenderLibrary spotlightIndexingPrevention:YES];
[MobileDefenderLibrary taskSwitcherBlurPrevention:YES];
[MobileDefenderLibrary storageEncryptionPrevention:YES];
[MobileDefenderLibrary tls13OnlyPrevention:YES];
[MobileDefenderLibrary backupProtection:YES];
[MobileDefenderLibrary keychainAccessibilityPrevention:YES];
[MobileDefenderLibrary keyboardCachePrevention:YES];
[MobileDefenderLibrary webViewHardeningPrevention:YES];
[MobileDefenderLibrary systemSharingPrevention:YES];

Keyboard cache and system sharing protections also expose helpers for sensitive UI:

[MobileDefenderLibrary markSensitive:passwordTextField];
[MobileDefenderLibrary markSensitiveViewController:accountViewController];

Prevention controls can also use the generic API. The control name must match one of the values returned by availablePreventionControls.

[MobileDefenderLibrary setPreventionControl:@"WebViewHardeningPrevention"
                                    enabled:YES
                              configuration:@{
                                  @"action": @"log"
                              }];

Runtime Inventory

Use these methods to inspect the control class names supported by the framework you embedded:

NSArray<NSString *> *detections = [MobileDefenderLibrary availableDetectionControls];
NSArray<NSString *> *preventions = [MobileDefenderLibrary availablePreventionControls];

Requirements

RequirementValue
Minimum iOS13.0
Device architecturearm64
Public API languageObjective-C headers, callable from Swift

appAttestCheck depends on Apple's App Attest support, which requires iOS 14.0 or later and a supported physical device. Validate App Attest behavior on physical devices.

Swift Usage

import MobileDefender
import UIKit

class AppDelegate: UIResponder, UIApplicationDelegate {
    var window: UIWindow?

    func application(_ application: UIApplication,
                     didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        guard let rootVC = window?.rootViewController else {
            return true
        }

        MobileDefenderLibrary.initialize(rootVC)

        MobileDefenderLibrary.jailbreakDetection(true) { controlName, message in
            print("Detection: \(controlName ?? "") - \(message ?? "")")
        }

        MobileDefenderLibrary.screenshotPrevention(true)

        return true
    }
}

Library Mode Release Checklist

CheckWhat to verify
IdentifierThe downloaded library was generated for the Android package name or iOS bundle ID you are shipping.
InitializationMobileDefender initializes before protected workflows need it.
Callback behaviorDetection callbacks route to the correct logging, messaging, analytics, or product behavior.
Control stateRuntime enable/disable decisions match your intended release behavior.
Platform testingAndroid and iOS behavior is validated on physical devices.
Dependency controlThe downloaded library is stored and versioned in your internal artifact process.
Release signingYour normal pipeline signs and distributes the final app artifact.