Check if app is on TestFlight/Google Play Beta

See original GitHub issue

This is a feature request, please let me know whether it’s valid for the project or not.


Description

A simply function that returns true if the app has been downloaded through TestFlight or Google Play Beta, e.g. isTesting().

The use-case is that I want to print out errors on screen if it’s on TestFlight and Build Configuration === 'Release' but not on production (downloaded from store).

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:44
  • Comments:18 (2 by maintainers)

github_iconTop GitHub Comments

29reactions
agates4commented, Sep 12, 2018

For those searching for a solution, here is the solution for iOS TestFlight. I am unaware of any google play solution.

In your Xcode workspace, create a file ProdChecker.h

#ifndef prodChecker_h
#define prodChecker_h

#import <React/RCTBridgeModule.h>

@interface ProdChecker : NSObject <RCTBridgeModule>
@end

#endif /* prodChecker_h */

In your Xcode workspace, create a file ProdChecker.m

#import "ProdChecker.h"

@implementation ProdChecker

RCT_EXPORT_MODULE();

RCT_REMAP_METHOD(isTestflight, resolver: (RCTPromiseResolveBlock)resolve
                 rejecter:(RCTPromiseRejectBlock)reject)
{
  NSURL *receiptURL = [[NSBundle mainBundle] appStoreReceiptURL];
  NSString *receiptURLString = [receiptURL path];
  BOOL isRunningTestFlightBeta =  ([receiptURLString rangeOfString:@"sandboxReceipt"].location != NSNotFound);
  if(isRunningTestFlightBeta) {
    NSString *thingToReturn = @"TESTFLIGHT";
    resolve(thingToReturn);
  } else {
    NSString *thingToReturn = @"PRODUCTION";
    resolve(thingToReturn);
  }
}

@end

Those are the files needed to call the objective-c functions from react native. The function above will determine if the app is on the App Store or on TestFlight.

And now the react-native implementation:

import { NativeModules } from 'react-native';
const ProdChecker = NativeModules.ProdChecker;
ProdChecker.isTestflight().then(val => {
    if(val != "TESTFLIGHT") {
        // app is in production on App Store, not TestFlight
        // execute all production specific code here 
    }
})

This way, you’ll be able to tell if the app is in production or not.

6reactions
kirill-konshincommented, Nov 3, 2018

I expect that 1 year old issue will be brought to your attention 😃 which could be annoying but that’s the best I could do now. If I could do a PR I would do it in a first place 😃 unfortunately, I don’t know the right solution, especially for Google Play.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Detect when app is in TestFlight? : r/reactnative
Hi! Is there any way to detect when an app is being used from a device using TestFlight, as opposed to in the...
Read more >
TestFlight - Apple Developer
TestFlight Beta Testing lets you invite users to beta test versions of your apps before you release them on the App Store.
Read more >
Detect if mobile app was installed from Production Track or ...
Android - The app is uploaded to the play store on the Beta Track and once testing is completed it is promoted the...
Read more >
Set up an open, closed, or internal test - Play Console Help
Open Play Console and go to the Open testing page (Testing > Open testing). Select the Testers tab. Expand the "Manage testers" section....
Read more >
Beta Apps Tips & Tricks
welcome TestFlight makes it easy to test beta versions of iOS, tvOS, and watchOS apps and App Clips, then provide valuable feedback to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found