Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SDK detection on Android and IOS

I'm currently developing a POC SDK, I need to add an ability to detect if any other 3rd party SDK's (from a finite list) are present on the current App that user my SDK.

For example, detecting that Google maps SDK is being used.

What would be the approaches of doing so on Android and on IOS?

like image 639
Roni Gadot Avatar asked May 25 '17 13:05

Roni Gadot


2 Answers

Android

  1. Pick a class from the library and try to load it using a classloader. Advantage: Unlikely to give false positives. Disadvantage: Fails if the class is obfuscated. This means it can only be used reliably on libraries which contain classes which cannot be obfuscated, like activities.
  2. Read the apk file and try to find the base package name of the library. Advantage: Doesn't fail on standard-issue proguarded apps. Disadvantage: Analysing classes.dex requires additional tools.
  3. Search for the library at compile time (e.g. with a gradle plugin). Advantage: Can plug in before proguard and similar tools. Disadvantage: Is bound to a specific build tool (e.g. gradle).
like image 72
F43nd1r Avatar answered Oct 11 '22 11:10

F43nd1r


IOS

Similar approach can be used for IOS as mentioned by @F43nd1r. Pick a public class and check if that is available or not.

Following is an example for Google Analytics. Google Analytics has a public class called GAI (API Reference). If GAI class is available we can assume app is using Google Analytics SDK.

if NSClassFromString("GAI") != nil {
    print("App is using Google Analytics SDK")
}

Android

Example for Google Analytics.

try {
    if (Class.forName("com.google.android.gms.analytics.GoogleAnalytics") != null) {
        Log.d(TAG, "App is using Google Analytics SDK");
    }
} catch (Exception ex) {

}
like image 29
Bilal Avatar answered Oct 11 '22 11:10

Bilal