Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS: Detect whether my SDK is installed on another apps on the device

Tags:

ios

sdk

udid

I am developing a location based Q&A SDK for mobile devices.

When a question is asked about a specific location, the server side targets the most relevant user and sends the question to that user. If the user fails to answer, the question is sent to the second best user, and so on.

The problem is that my SDK might be installed on more than one application on the device, meaning that the user can get a question more than once.

Is there a way to detect whether my SDK is installed on more than one app? I thought that sending the UDID to the server might work, but iOS UDIDs differ between applications.

like image 493
Adam Matan Avatar asked Jun 16 '14 22:06

Adam Matan


People also ask

How do you know which SDKs are installed on a mobile app?

To find out which SDKs are inside a mobile app, you can rely on app intelligence tools such as App Annie, Apptopia or 42 Matters. They provide a great way to see at a given time, how many apps use a certain SDK, be it for ad monetization, attribution, analytics, CRM, user support, etc.

How do you check programmatically if an application is installed or not in iOS?

To check if an application is currently installed on the device, use the isApplicationInstalled method. This method takes the application identifier ( bundle id for iOS, or package id for Android) and returns True or False .

How do you tell if an app has been installed on iPhone?

Go to the Home Screen, then swipe left past all your Home Screen pages to get to App Library. Tap the search field at the top of the screen, then enter the name of the app you're looking for. Or scroll up and down to browse the alphabetical list. To open an app, tap it.

How does an app know it has been installed on a device before?

How does an app know it has been installed on a device before? Each device has its unique device ID. So once you have installed an app, they have your device ID and if you try to install again, they'll detect. They also use your account ID to detect your install/login.


2 Answers

You can use UIPasteboard to share data between applications on the device.

The UIPasteboard class enables an app to share data within the app and with another app. To share data with any other app, you can use system-wide pasteboards; to share data with another app that has the same team ID as your app, you can use app-specific pasteboards.

In your SDK, do something like this:

@interface SDKDetector : NSObject

@end

@implementation SDKDetector

+ (void)load
{
    int numberOfApps = (int)[self numberOfAppsInDeviceUsingSDK];
    NSLog(@"Number of apps using sdk:%d", numberOfApps);
}

+ (NSInteger)numberOfAppsInDeviceUsingSDK
{
    static NSString *pasteboardType = @"mySDKPasteboardUniqueKey";

    NSData *value = [[UIPasteboard generalPasteboard] valueForPasteboardType:pasteboardType];
    NSMutableArray *storedData = [[NSKeyedUnarchiver unarchiveObjectWithData:value] mutableCopy];

    if (!storedData) {
        storedData = [NSMutableArray new];
    }

    NSString *bundleId = [[NSBundle mainBundle] bundleIdentifier];
    if (![storedData containsObject:bundleId]) {
        [storedData addObject:[[NSBundle mainBundle] bundleIdentifier]];
    }

    value = [NSKeyedArchiver archivedDataWithRootObject:storedData];
    [[UIPasteboard generalPasteboard] setData:value forPasteboardType:pasteboardType];

    return [storedData count];
}

@end
like image 86
arturdev Avatar answered Oct 15 '22 09:10

arturdev


If you only want to provide an SDK, it is not possible. Apple has added security steps to prevent that for user privacy. Keychain sharing will not work, because apps must share the same bundle seed ID (see here for more info).

If you want to provide an app along with your SDK, then you could do something like Facebook does, where app sends a "helo" message, Facebook asks user and finally Facebook sends "ehlo" message.

Your App -> "I would like to use the SDK; please give me token" -> SDK Controller App -> (Remember which apps have requested use) -> "OK, you can use the SDK; here is a token: #123" -> Your App

The SDK controller app can now send the server the list of apps.

like image 43
Léo Natan Avatar answered Oct 15 '22 09:10

Léo Natan