Detect Testflight

Detect TestFlight?

I believe this to be close enough to a duplicate of Check if iOS app is live in app store that this can be closed.

You can determine if your app was distributed via the app store by checking for the absence of embedded.mobileprovision. This file is only included in adhoc builds. It follows that if you're distributing builds only via TestFlight or HockeyApp and it is not a store build, it must be a TestFlight or HockeyApp build.

Like this:

if ([[NSBundle mainBundle] pathForResource:@"embedded"
ofType:@"mobileprovision"]) {
// not from app store
} else {
// from app store
}

This technique is from the HockeyApp SDK.

How to tell at runtime whether an iOS app is running through a TestFlight Beta install

For an application installed through TestFlight Beta the receipt file is named StoreKit/sandboxReceipt vs the usual StoreKit/receipt. Using [NSBundle appStoreReceiptURL] you can look for sandboxReceipt at the end of the URL.

NSURL *receiptURL = [[NSBundle mainBundle] appStoreReceiptURL];
NSString *receiptURLString = [receiptURL path];
BOOL isRunningTestFlightBeta = ([receiptURLString rangeOfString:@"sandboxReceipt"].location != NSNotFound);

Note that sandboxReceipt is also the name of the receipt file when running builds locally and for builds run in the simulator.

Swift Version:

let isTestFlight = Bundle.main.appStoreReceiptURL?.lastPathComponent == "sandboxReceipt"

How to identify the app running environment including Test Flight

If you are asking to get this information from within the app, you can get all this from appStoreReceiptURL of NSBundle

From apple documentation...

For an application purchased from the App Store, use this application bundle property to locate the receipt. This property makes no guarantee about whether there is a file at the URL—only that if a receipt is present, that is its location.

NSBundle.mainBundle().appStoreReceiptURL?.lastPathComponent

For implementation refer to this question

How to know installed application is installed via TestFlight or AppStore?

I found little snippet about how to know if application is installed via TestFlight.

Here, appStoreReceiptURL is an instance property, which we can find from main bundle.

Sample Image

func isTestFlight() -> Bool {
guard let appStoreReceiptURL = Bundle.main.appStoreReceiptURL else {
return false
}
return appStoreReceiptURL.lastPathComponent == "sandboxReceipt"
}

Detect if iOS App is Downloaded from Apple's Testflight

This works:

if ([[NSBundle mainBundle] pathForResource:@"embedded" ofType:@"mobileprovision"]) {
// TestFlight
} else {
// App Store (and Apple reviewers too)
}

Update

The above method doesn't seem to work anymore, Apple changed the way they sign TestFlight builds. This does work however:

BOOL isRunningTestFlightBeta = [[[[NSBundle mainBundle] appStoreReceiptURL] lastPathComponent] isEqualToString:@"sandboxReceipt"];

How can I programmatically check if an app is running in TestFlight beta mode?

Try this code:

    if ([[NSBundle mainBundle] pathForResource:@"embedded"
ofType:@"mobileprovision"]) {
// not from app store, eg: testflight or others
} else {
// from app store

}

Refferece answer from here



Related Topics



Leave a reply



Submit