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.
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
Instantiateviewcontrollerwithidentifier - Storyboard Id Set But Still Not Working
Mapkit Annotations Disappearing
How to Get Current Location Using Cllocationmanager in iOS
Keep Getting "Unbalanced Calls to Begin/End Appearance Transitions for <Viewcontroller>" Error
App Is Not Showing in the Share Menu of Shared Options in Shared Extension in iOS8
How to Take Uiimage of Avcapturevideopreviewlayer Instead of Avcapturephotooutput Capture
Making Phone Calls on the Iphone
Xcode 5 - "No Application Records Were Found" When Trying to Validate an Archive
Custom Uisearchbar with Uisearchcontroller
Dismiss and Present View Controller in Swift
iOS Web App: Showing Content Only If the Application Is Standalone
iOS Autolayout - Frame Size Not Set in Viewdidlayoutsubviews
Insert String at Cursor Position of Uitextfield
Measuring Time Accurately in Swift for Comparison Across Devices
Which Phassetcollection to Use for Saving an Image
iOS 11 - Unable to Change Navigation Bar Height
How to Use Nsurlsession to Determine If Resource Has Changed