1 | //
|
2 | // EnvironmentUtil.m
|
3 | // RNDeviceInfo
|
4 | //
|
5 | // Created by Dima Portenko on 10.04.2021.
|
6 | // Copyright © 2021 Learnium. All rights reserved.
|
7 | //
|
8 |
|
9 | #import "EnvironmentUtil.h"
|
10 |
|
11 | @implementation EnvironmentUtil
|
12 |
|
13 | + (MSACEnvironment)currentAppEnvironment {
|
14 | #if TARGET_OS_SIMULATOR || TARGET_OS_OSX || TARGET_OS_MACCATALYST
|
15 | return MSACEnvironmentOther;
|
16 | #else
|
17 |
|
18 | // MobilePovision profiles are a clear indicator for Ad-Hoc distribution.
|
19 | if ([self hasEmbeddedMobileProvision]) {
|
20 | return MSACEnvironmentOther;
|
21 | }
|
22 |
|
23 | |
24 |
|
25 |
|
26 |
|
27 | if ([self isAppStoreReceiptSandbox]) {
|
28 | return MSACEnvironmentTestFlight;
|
29 | }
|
30 |
|
31 | return MSACEnvironmentAppStore;
|
32 | #endif
|
33 | }
|
34 |
|
35 | + (BOOL)hasEmbeddedMobileProvision {
|
36 | BOOL hasEmbeddedMobileProvision = !![[NSBundle mainBundle] pathForResource:@"embedded" ofType:@"mobileprovision"];
|
37 | return hasEmbeddedMobileProvision;
|
38 | }
|
39 |
|
40 | + (BOOL)isAppStoreReceiptSandbox {
|
41 | #if TARGET_OS_SIMULATOR
|
42 | return NO;
|
43 | #else
|
44 | if (![NSBundle.mainBundle respondsToSelector:@selector(appStoreReceiptURL)]) {
|
45 | return NO;
|
46 | }
|
47 | NSURL *appStoreReceiptURL = NSBundle.mainBundle.appStoreReceiptURL;
|
48 | NSString *appStoreReceiptLastComponent = appStoreReceiptURL.lastPathComponent;
|
49 |
|
50 | BOOL isSandboxReceipt = [appStoreReceiptLastComponent isEqualToString:@"sandboxReceipt"];
|
51 | return isSandboxReceipt;
|
52 | #endif
|
53 | }
|
54 |
|
55 | @end
|