expo-application 58.0.3 → 58.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/android/build.gradle +7 -2
  3. package/android/src/main/java/expo/modules/application/ApplicationExceptions.kt +25 -0
  4. package/android/src/main/java/expo/modules/application/ApplicationModule.kt +83 -101
  5. package/build/Application.d.ts +20 -2
  6. package/build/Application.js +22 -0
  7. package/build/Application.js.map +1 -1
  8. package/build/Application.types.d.ts +16 -0
  9. package/expo-module.config.json +0 -1
  10. package/ios/ApplicationModule.swift +22 -0
  11. package/ios/ExpoApplication.podspec +3 -0
  12. package/local-maven-repo/host/exp/exponent/expo.modules.application/58.1.0/expo.modules.application-58.1.0-sources.jar +0 -0
  13. package/local-maven-repo/host/exp/exponent/expo.modules.application/58.1.0/expo.modules.application-58.1.0-sources.jar.md5 +1 -0
  14. package/local-maven-repo/host/exp/exponent/expo.modules.application/58.1.0/expo.modules.application-58.1.0-sources.jar.sha1 +1 -0
  15. package/local-maven-repo/host/exp/exponent/expo.modules.application/58.1.0/expo.modules.application-58.1.0-sources.jar.sha256 +1 -0
  16. package/local-maven-repo/host/exp/exponent/expo.modules.application/58.1.0/expo.modules.application-58.1.0-sources.jar.sha512 +1 -0
  17. package/local-maven-repo/host/exp/exponent/expo.modules.application/58.1.0/expo.modules.application-58.1.0.aar +0 -0
  18. package/local-maven-repo/host/exp/exponent/expo.modules.application/58.1.0/expo.modules.application-58.1.0.aar.md5 +1 -0
  19. package/local-maven-repo/host/exp/exponent/expo.modules.application/58.1.0/expo.modules.application-58.1.0.aar.sha1 +1 -0
  20. package/local-maven-repo/host/exp/exponent/expo.modules.application/58.1.0/expo.modules.application-58.1.0.aar.sha256 +1 -0
  21. package/local-maven-repo/host/exp/exponent/expo.modules.application/58.1.0/expo.modules.application-58.1.0.aar.sha512 +1 -0
  22. package/local-maven-repo/host/exp/exponent/expo.modules.application/{58.0.3/expo.modules.application-58.0.3.module → 58.1.0/expo.modules.application-58.1.0.module} +22 -22
  23. package/local-maven-repo/host/exp/exponent/expo.modules.application/58.1.0/expo.modules.application-58.1.0.module.md5 +1 -0
  24. package/local-maven-repo/host/exp/exponent/expo.modules.application/58.1.0/expo.modules.application-58.1.0.module.sha1 +1 -0
  25. package/local-maven-repo/host/exp/exponent/expo.modules.application/58.1.0/expo.modules.application-58.1.0.module.sha256 +1 -0
  26. package/local-maven-repo/host/exp/exponent/expo.modules.application/58.1.0/expo.modules.application-58.1.0.module.sha512 +1 -0
  27. package/local-maven-repo/host/exp/exponent/expo.modules.application/{58.0.3/expo.modules.application-58.0.3.pom → 58.1.0/expo.modules.application-58.1.0.pom} +1 -1
  28. package/local-maven-repo/host/exp/exponent/expo.modules.application/58.1.0/expo.modules.application-58.1.0.pom.md5 +1 -0
  29. package/local-maven-repo/host/exp/exponent/expo.modules.application/58.1.0/expo.modules.application-58.1.0.pom.sha1 +1 -0
  30. package/local-maven-repo/host/exp/exponent/expo.modules.application/58.1.0/expo.modules.application-58.1.0.pom.sha256 +1 -0
  31. package/local-maven-repo/host/exp/exponent/expo.modules.application/58.1.0/expo.modules.application-58.1.0.pom.sha512 +1 -0
  32. package/package.json +6 -4
  33. package/src/Application.ts +26 -0
  34. package/src/Application.types.ts +17 -0
  35. package/local-maven-repo/host/exp/exponent/expo.modules.application/58.0.3/expo.modules.application-58.0.3-sources.jar +0 -0
  36. package/local-maven-repo/host/exp/exponent/expo.modules.application/58.0.3/expo.modules.application-58.0.3-sources.jar.md5 +0 -1
  37. package/local-maven-repo/host/exp/exponent/expo.modules.application/58.0.3/expo.modules.application-58.0.3-sources.jar.sha1 +0 -1
  38. package/local-maven-repo/host/exp/exponent/expo.modules.application/58.0.3/expo.modules.application-58.0.3-sources.jar.sha256 +0 -1
  39. package/local-maven-repo/host/exp/exponent/expo.modules.application/58.0.3/expo.modules.application-58.0.3-sources.jar.sha512 +0 -1
  40. package/local-maven-repo/host/exp/exponent/expo.modules.application/58.0.3/expo.modules.application-58.0.3.aar +0 -0
  41. package/local-maven-repo/host/exp/exponent/expo.modules.application/58.0.3/expo.modules.application-58.0.3.aar.md5 +0 -1
  42. package/local-maven-repo/host/exp/exponent/expo.modules.application/58.0.3/expo.modules.application-58.0.3.aar.sha1 +0 -1
  43. package/local-maven-repo/host/exp/exponent/expo.modules.application/58.0.3/expo.modules.application-58.0.3.aar.sha256 +0 -1
  44. package/local-maven-repo/host/exp/exponent/expo.modules.application/58.0.3/expo.modules.application-58.0.3.aar.sha512 +0 -1
  45. package/local-maven-repo/host/exp/exponent/expo.modules.application/58.0.3/expo.modules.application-58.0.3.module.md5 +0 -1
  46. package/local-maven-repo/host/exp/exponent/expo.modules.application/58.0.3/expo.modules.application-58.0.3.module.sha1 +0 -1
  47. package/local-maven-repo/host/exp/exponent/expo.modules.application/58.0.3/expo.modules.application-58.0.3.module.sha256 +0 -1
  48. package/local-maven-repo/host/exp/exponent/expo.modules.application/58.0.3/expo.modules.application-58.0.3.module.sha512 +0 -1
  49. package/local-maven-repo/host/exp/exponent/expo.modules.application/58.0.3/expo.modules.application-58.0.3.pom.md5 +0 -1
  50. package/local-maven-repo/host/exp/exponent/expo.modules.application/58.0.3/expo.modules.application-58.0.3.pom.sha1 +0 -1
  51. package/local-maven-repo/host/exp/exponent/expo.modules.application/58.0.3/expo.modules.application-58.0.3.pom.sha256 +0 -1
  52. package/local-maven-repo/host/exp/exponent/expo.modules.application/58.0.3/expo.modules.application-58.0.3.pom.sha512 +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 58.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [iOS] Add `getAppleStoreEnvironmentAsync()`, which returns StoreKit's App Store environment for the running build (`'production'`, `'sandbox'` or `'xcode'`), so apps can tell TestFlight, App Review and development builds apart from App Store releases. ([#51209](https://github.com/expo/expo/pull/51209) by [@huntie](https://github.com/huntie))
8
+
9
+ ## 58.0.4
10
+
11
+ ### Patch Changes
12
+
13
+ - [Android] Migrate to the Expo Modules API 2.0. ([#51077](https://github.com/expo/expo/pull/51077) by [@lukmccall](https://github.com/lukmccall))
14
+
3
15
  ## 58.0.3
4
16
 
5
17
  ### Patch Changes
@@ -4,13 +4,17 @@ plugins {
4
4
  }
5
5
 
6
6
  group = 'host.exp.exponent'
7
- version = '58.0.3'
7
+ version = '58.1.0'
8
+
9
+ expoModule {
10
+ v2 true
11
+ }
8
12
 
9
13
  android {
10
14
  namespace "expo.modules.application"
11
15
  defaultConfig {
12
16
  versionCode 12
13
- versionName '58.0.3'
17
+ versionName '58.1.0'
14
18
  }
15
19
  }
16
20
 
@@ -21,5 +25,6 @@ dependencies {
21
25
  testImplementation project(':expo-modules-test-core')
22
26
  }
23
27
  testImplementation "org.robolectric:robolectric:4.16"
28
+ testImplementation 'com.facebook.react:react-android'
24
29
  testImplementation 'junit:junit:4.13.2'
25
30
  }
@@ -0,0 +1,25 @@
1
+ package expo.modules.application
2
+
3
+ import android.content.pm.PackageManager
4
+ import android.os.RemoteException
5
+ import expo.modules.kotlin.exception.CodedException
6
+
7
+ class ApplicationPackageNameNotFoundException(cause: PackageManager.NameNotFoundException) :
8
+ CodedException(message = "Unable to get install time of this application. Could not get package info or package name.", cause = cause)
9
+
10
+ // The code is set explicitly, because the one inferred from the class name drops the `_EXCEPTION` suffix.
11
+ internal class ApplicationInstallReferrerRemoteException(cause: RemoteException) :
12
+ CodedException(
13
+ "ERR_APPLICATION_INSTALL_REFERRER_REMOTE_EXCEPTION",
14
+ "RemoteException getting install referrer information. This may happen if the process hosting the remote object is no longer available.",
15
+ cause
16
+ )
17
+
18
+ internal class ApplicationInstallReferrerUnavailableException :
19
+ CodedException("The current Play Store app doesn't provide the installation referrer API, or the Play Store may not be installed.")
20
+
21
+ internal class ApplicationInstallReferrerException(responseCode: Int) :
22
+ CodedException("General error retrieving the install referrer: response code $responseCode")
23
+
24
+ internal class ApplicationInstallReferrerServiceDisconnectedException :
25
+ CodedException("Connection to install referrer service was lost.")
@@ -1,6 +1,6 @@
1
1
  package expo.modules.application
2
2
 
3
- import android.content.Context
3
+ import android.annotation.SuppressLint
4
4
  import android.content.pm.PackageInfo
5
5
  import android.content.pm.PackageManager
6
6
  import android.os.Build
@@ -8,120 +8,102 @@ import android.os.RemoteException
8
8
  import android.provider.Settings
9
9
  import com.android.installreferrer.api.InstallReferrerClient
10
10
  import com.android.installreferrer.api.InstallReferrerStateListener
11
- import expo.modules.kotlin.Promise
12
- import expo.modules.kotlin.exception.CodedException
13
- import expo.modules.kotlin.exception.Exceptions
14
- import expo.modules.kotlin.modules.Module
15
- import expo.modules.kotlin.modules.ModuleDefinition
16
-
17
- class ApplicationPackageNameNotFoundException(cause: PackageManager.NameNotFoundException) :
18
- CodedException(message = "Unable to get install time of this application. Could not get package info or package name.", cause = cause)
19
-
11
+ import io.github.expo.modules.v2.Constant
12
+ import io.github.expo.modules.v2.ExpoModule
13
+ import io.github.expo.modules.v2.JS
14
+ import io.github.expo.modules.v2.Module
15
+ import io.github.expo.modules.v2.react.androidContext
16
+ import kotlinx.coroutines.Dispatchers
17
+ import kotlinx.coroutines.suspendCancellableCoroutine
18
+ import kotlinx.coroutines.withContext
19
+ import kotlin.coroutines.resume
20
+ import kotlin.coroutines.resumeWithException
21
+
22
+ @ExpoModule("ExpoApplication")
20
23
  class ApplicationModule : Module() {
21
- private val context: Context
22
- get() = appContext.reactContext ?: throw Exceptions.ReactContextLost()
23
-
24
- override fun definition() = ModuleDefinition {
25
- Name("ExpoApplication")
26
-
27
- Constant("applicationName") {
28
- context.applicationInfo.loadLabel(context.packageManager).toString()
29
- }
30
-
31
- Constant("applicationId") {
32
- packageName
33
- }
34
-
35
- Constant("nativeApplicationVersion") {
36
- packageManager.getPackageInfoCompat(packageName, 0).versionName
37
- }
38
-
39
- Constant("nativeBuildVersion") {
40
- getLongVersionCode(packageManager.getPackageInfoCompat(packageName, 0)).toInt().toString()
41
- }
42
-
43
- Constant("androidId") {
44
- Settings.Secure.getString(context.contentResolver, Settings.Secure.ANDROID_ID)
45
- }
46
-
47
- AsyncFunction<Double>("getInstallationTimeAsync") {
48
- val packageManager = context.packageManager
49
- val packageName = context.packageName
50
- packageManager
51
- .getPackageInfoCompat(packageName, 0)
52
- .firstInstallTime
53
- .toDouble()
54
- }
55
-
56
- AsyncFunction<Double>("getLastUpdateTimeAsync") {
57
- val packageManager = context.packageManager
58
- val packageName = context.packageName
59
- packageManager
60
- .getPackageInfoCompat(packageName, 0)
61
- .lastUpdateTime
62
- .toDouble()
63
- }
64
-
65
- AsyncFunction("getInstallReferrerAsync") { promise: Promise ->
66
- val installReferrer = StringBuilder()
67
- var isSettled = false
24
+ private val packageInfo: PackageInfo
25
+ get() = androidContext.packageManager.getPackageInfoCompat(androidContext.packageName)
26
+
27
+ @JS
28
+ @Constant
29
+ val applicationName: String
30
+ get() = androidContext.applicationInfo.loadLabel(androidContext.packageManager).toString()
31
+
32
+ @JS
33
+ @Constant
34
+ val applicationId: String
35
+ get() = androidContext.packageName
36
+
37
+ @JS
38
+ @Constant
39
+ val nativeApplicationVersion: String?
40
+ get() = packageInfo.versionName
41
+
42
+ @JS
43
+ @Constant
44
+ val nativeBuildVersion: String
45
+ get() = getLongVersionCode(packageInfo).toInt().toString()
46
+
47
+ @JS
48
+ @Constant
49
+ @get:SuppressLint("HardwareIds")
50
+ val androidId: String?
51
+ get() = Settings.Secure.getString(androidContext.contentResolver, Settings.Secure.ANDROID_ID)
52
+
53
+ @JS
54
+ suspend fun getInstallationTimeAsync(): Double = withContext(Dispatchers.IO) {
55
+ packageInfo.firstInstallTime.toDouble()
56
+ }
68
57
 
69
- val referrerClient = InstallReferrerClient.newBuilder(context).build()
58
+ @JS
59
+ suspend fun getLastUpdateTimeAsync(): Double = withContext(Dispatchers.IO) {
60
+ packageInfo.lastUpdateTime.toDouble()
61
+ }
70
62
 
71
- referrerClient.startConnection(object : InstallReferrerStateListener {
72
- override fun onInstallReferrerSetupFinished(responseCode: Int) {
73
- if (isSettled) {
74
- return
75
- }
63
+ @JS
64
+ suspend fun getInstallReferrerAsync(): String = suspendCancellableCoroutine { continuation ->
65
+ val referrerClient = InstallReferrerClient.newBuilder(androidContext).build()
76
66
 
77
- when (responseCode) {
78
- InstallReferrerClient.InstallReferrerResponse.OK -> {
79
- // Connection established and response received
80
- try {
81
- val response = referrerClient.installReferrer
82
- installReferrer.append(response.installReferrer)
83
- } catch (e: RemoteException) {
84
- promise.reject("ERR_APPLICATION_INSTALL_REFERRER_REMOTE_EXCEPTION", "RemoteException getting install referrer information. This may happen if the process hosting the remote object is no longer available.", e)
85
- return
86
- } finally {
87
- isSettled = true
88
- }
89
- promise.resolve(installReferrer.toString())
90
- }
67
+ val listener = object : InstallReferrerStateListener {
68
+ override fun onInstallReferrerSetupFinished(responseCode: Int) {
69
+ if (!continuation.isActive) {
70
+ return
71
+ }
91
72
 
92
- InstallReferrerClient.InstallReferrerResponse.FEATURE_NOT_SUPPORTED -> { // API not available in the current Play Store app
93
- isSettled = true
94
- promise.reject("ERR_APPLICATION_INSTALL_REFERRER_UNAVAILABLE", "The current Play Store app doesn't provide the installation referrer API, or the Play Store may not be installed.", null)
73
+ when (responseCode) {
74
+ InstallReferrerClient.InstallReferrerResponse.OK -> {
75
+ // Connection established and response received
76
+ try {
77
+ val installReferrer: String? = referrerClient.installReferrer.installReferrer
78
+ continuation.resume(installReferrer.toString())
79
+ } catch (e: RemoteException) {
80
+ continuation.resumeWithException(ApplicationInstallReferrerRemoteException(e))
95
81
  }
82
+ }
96
83
 
97
- InstallReferrerClient.InstallReferrerResponse.SERVICE_UNAVAILABLE -> { // Connection could not be established
98
- isSettled = true
99
- promise.reject("ERR_APPLICATION_INSTALL_REFERRER", "General error retrieving the install referrer: response code $responseCode", null)
100
- }
84
+ InstallReferrerClient.InstallReferrerResponse.FEATURE_NOT_SUPPORTED -> {
85
+ // API not available in the current Play Store app
86
+ continuation.resumeWithException(ApplicationInstallReferrerUnavailableException())
87
+ }
101
88
 
102
- else -> {
103
- isSettled = true
104
- promise.reject("ERR_APPLICATION_INSTALL_REFERRER", "General error retrieving the install referrer: response code $responseCode", null)
105
- }
89
+ else -> {
90
+ // Includes SERVICE_UNAVAILABLE, when the connection could not be established
91
+ continuation.resumeWithException(ApplicationInstallReferrerException(responseCode))
106
92
  }
107
- referrerClient.endConnection()
108
93
  }
94
+ referrerClient.endConnection()
95
+ }
109
96
 
110
- override fun onInstallReferrerServiceDisconnected() {
111
- if (isSettled) {
112
- return
113
- }
114
- isSettled = true
115
- promise.reject("ERR_APPLICATION_INSTALL_REFERRER_SERVICE_DISCONNECTED", "Connection to install referrer service was lost.", null)
97
+ override fun onInstallReferrerServiceDisconnected() {
98
+ if (!continuation.isActive) {
99
+ return
116
100
  }
117
- })
101
+ continuation.resumeWithException(ApplicationInstallReferrerServiceDisconnectedException())
102
+ }
118
103
  }
119
- }
120
104
 
121
- private val packageName
122
- get() = context.packageName
123
- private val packageManager
124
- get() = context.packageManager
105
+ referrerClient.startConnection(listener)
106
+ }
125
107
  }
126
108
 
127
109
  private fun PackageManager.getPackageInfoCompat(packageName: String, flags: Int = 0): PackageInfo =
@@ -1,4 +1,4 @@
1
- import type { ApplicationReleaseType, PushNotificationServiceEnvironment } from './Application.types';
1
+ import type { ApplicationReleaseType, PushNotificationServiceEnvironment, AppleAppStoreEnvironment } from './Application.types';
2
2
  /**
3
3
  * The human-readable version of the native application that may be displayed in the app store.
4
4
  * At time when native app is built, on Android, this is the version name set by `version`
@@ -91,6 +91,24 @@ export declare function getIosIdForVendorAsync(): Promise<string | null>;
91
91
  * @platform ios
92
92
  */
93
93
  export declare function getIosApplicationReleaseTypeAsync(): Promise<ApplicationReleaseType>;
94
+ /**
95
+ * Gets the App Store environment of the running build. Unlike
96
+ * [`getIosApplicationReleaseTypeAsync`](#applicationgetiosapplicationreleasetypeasync), which
97
+ * reports `APP_STORE` for both a TestFlight build and an App Store release, this tells them apart.
98
+ * In Expo Go, this reports Expo Go's own environment.
99
+ *
100
+ * @example
101
+ * ```ts
102
+ * if ((await Application.getAppleStoreEnvironmentAsync()) === 'sandbox') {
103
+ * // Show settings for TestFlight testers, App Review and development builds
104
+ * }
105
+ * ```
106
+ * @return A `Promise` which fulfills with an
107
+ * [`AppleAppStoreEnvironment`](#appleappstoreenvironment).
108
+ * @platform ios
109
+ * @platform tvos
110
+ */
111
+ export declare function getAppleStoreEnvironmentAsync(): Promise<AppleAppStoreEnvironment>;
94
112
  /**
95
113
  * Gets the current [Apple Push Notification (APN)](https://developer.apple.com/documentation/bundleresources/entitlements/aps-environment?language=objc)
96
114
  * service environment.
@@ -130,4 +148,4 @@ export declare function getInstallationTimeAsync(): Promise<Date>;
130
148
  * @platform android
131
149
  */
132
150
  export declare function getLastUpdateTimeAsync(): Promise<Date>;
133
- export { ApplicationReleaseType, type PushNotificationServiceEnvironment, } from './Application.types';
151
+ export { ApplicationReleaseType, type PushNotificationServiceEnvironment, type AppleAppStoreEnvironment, } from './Application.types';
@@ -112,6 +112,28 @@ import ExpoApplication from './ExpoApplication';
112
112
  }
113
113
  return await ExpoApplication.getApplicationReleaseTypeAsync();
114
114
  }
115
+ /**
116
+ * Gets the App Store environment of the running build. Unlike
117
+ * [`getIosApplicationReleaseTypeAsync`](#applicationgetiosapplicationreleasetypeasync), which
118
+ * reports `APP_STORE` for both a TestFlight build and an App Store release, this tells them apart.
119
+ * In Expo Go, this reports Expo Go's own environment.
120
+ *
121
+ * @example
122
+ * ```ts
123
+ * if ((await Application.getAppleStoreEnvironmentAsync()) === 'sandbox') {
124
+ * // Show settings for TestFlight testers, App Review and development builds
125
+ * }
126
+ * ```
127
+ * @return A `Promise` which fulfills with an
128
+ * [`AppleAppStoreEnvironment`](#appleappstoreenvironment).
129
+ * @platform ios
130
+ * @platform tvos
131
+ */ export async function getAppleStoreEnvironmentAsync() {
132
+ if (!ExpoApplication.getStoreEnvironmentAsync) {
133
+ throw new UnavailabilityError('expo-application', 'getStoreEnvironmentAsync');
134
+ }
135
+ return await ExpoApplication.getStoreEnvironmentAsync();
136
+ }
115
137
  // @needsAudit
116
138
  /**
117
139
  * Gets the current [Apple Push Notification (APN)](https://developer.apple.com/documentation/bundleresources/entitlements/aps-environment?language=objc)
@@ -1 +1 @@
1
- {"version":3,"sources":["Application.ts"],"sourcesContent":[null],"names":["Platform","UnavailabilityError","ExpoApplication","nativeApplicationVersion","nativeBuildVersion","applicationName","applicationId","getAndroidId","OS","androidId","getInstallReferrerAsync","getIosIdForVendorAsync","getIosApplicationReleaseTypeAsync","getApplicationReleaseTypeAsync","getIosPushNotificationServiceEnvironmentAsync","getPushNotificationServiceEnvironmentAsync","getInstallationTimeAsync","installationTime","Date","getLastUpdateTimeAsync","lastUpdateTime","ApplicationReleaseType"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,mBAAmB,QAAQ,OAAO;AAMrD,OAAOC,qBAAqB,oBAAoB;AAEhD,cAAc;AACd;;;;;;;CAOC,GACD,OAAO,MAAMC,2BAA0CD,kBACnDA,gBAAgBC,wBAAwB,IAAI,OAC5C,KAAK;AAET,cAAc;AACd;;;;;;;;CAQC,GACD,OAAO,MAAMC,qBAAoCF,kBAC7CA,gBAAgBE,kBAAkB,IAAI,OACtC,KAAK;AAET,cAAc;AACd;;;;;;CAMC,GACD,OAAO,MAAMC,kBAAiCH,kBAC1CA,gBAAgBG,eAAe,IAAI,OACnC,KAAK;AAET,cAAc;AACd;;;;;CAKC,GACD,OAAO,MAAMC,gBAA+BJ,kBACxCA,gBAAgBI,aAAa,IAAI,OACjC,KAAK;AAET,cAAc;AACd;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,SAASC;IACd,IAAIP,SAASQ,EAAE,KAAK,WAAW;QAC7B,MAAM,IAAIP,oBAAoB,oBAAoB;IACpD;IACA,OAAOC,gBAAgBO,SAAS;AAClC;AAEA,cAAc;AACd;;;;;;;;;;;CAWC,GACD,OAAO,eAAeC;IACpB,IAAI,CAACR,gBAAgBQ,uBAAuB,EAAE;QAC5C,MAAM,IAAIT,oBAAoB,oBAAoB;IACpD;IACA,OAAO,MAAMC,gBAAgBQ,uBAAuB;AACtD;AAEA,cAAc;AACd;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,eAAeC;IACpB,IAAI,CAACT,gBAAgBS,sBAAsB,EAAE;QAC3C,MAAM,IAAIV,oBAAoB,oBAAoB;IACpD;IACA,OAAO,MAAMC,gBAAgBS,sBAAsB;AACrD;AAEA,cAAc;AACd;;;;CAIC,GACD,OAAO,eAAeC;IACpB,IAAI,CAACV,gBAAgBW,8BAA8B,EAAE;QACnD,MAAM,IAAIZ,oBAAoB,oBAAoB;IACpD;IACA,OAAO,MAAMC,gBAAgBW,8BAA8B;AAC7D;AAEA,cAAc;AACd;;;;;;CAMC,GACD,OAAO,eAAeC;IACpB,IAAI,CAACZ,gBAAgBa,0CAA0C,EAAE;QAC/D,MAAM,IAAId,oBAAoB,oBAAoB;IACpD;IACA,OAAO,MAAMC,gBAAgBa,0CAA0C;AACzE;AAEA,cAAc;AACd;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,eAAeC;IACpB,IAAI,CAACd,gBAAgBc,wBAAwB,EAAE;QAC7C,MAAM,IAAIf,oBAAoB,oBAAoB;IACpD;IACA,MAAMgB,mBAAmB,MAAMf,gBAAgBc,wBAAwB;IACvE,OAAO,IAAIE,KAAKD;AAClB;AAEA,cAAc;AACd;;;;;;;;;;;CAWC,GACD,OAAO,eAAeE;IACpB,IAAI,CAACjB,gBAAgBiB,sBAAsB,EAAE;QAC3C,MAAM,IAAIlB,oBAAoB,oBAAoB;IACpD;IACA,MAAMmB,iBAAiB,MAAMlB,gBAAgBiB,sBAAsB;IACnE,OAAO,IAAID,KAAKE;AAClB;AAEA,SACEC,sBAAsB,QAEjB,sBAAsB"}
1
+ {"version":3,"sources":["Application.ts"],"sourcesContent":[null],"names":["Platform","UnavailabilityError","ExpoApplication","nativeApplicationVersion","nativeBuildVersion","applicationName","applicationId","getAndroidId","OS","androidId","getInstallReferrerAsync","getIosIdForVendorAsync","getIosApplicationReleaseTypeAsync","getApplicationReleaseTypeAsync","getAppleStoreEnvironmentAsync","getStoreEnvironmentAsync","getIosPushNotificationServiceEnvironmentAsync","getPushNotificationServiceEnvironmentAsync","getInstallationTimeAsync","installationTime","Date","getLastUpdateTimeAsync","lastUpdateTime","ApplicationReleaseType"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,mBAAmB,QAAQ,OAAO;AAOrD,OAAOC,qBAAqB,oBAAoB;AAEhD,cAAc;AACd;;;;;;;CAOC,GACD,OAAO,MAAMC,2BAA0CD,kBACnDA,gBAAgBC,wBAAwB,IAAI,OAC5C,KAAK;AAET,cAAc;AACd;;;;;;;;CAQC,GACD,OAAO,MAAMC,qBAAoCF,kBAC7CA,gBAAgBE,kBAAkB,IAAI,OACtC,KAAK;AAET,cAAc;AACd;;;;;;CAMC,GACD,OAAO,MAAMC,kBAAiCH,kBAC1CA,gBAAgBG,eAAe,IAAI,OACnC,KAAK;AAET,cAAc;AACd;;;;;CAKC,GACD,OAAO,MAAMC,gBAA+BJ,kBACxCA,gBAAgBI,aAAa,IAAI,OACjC,KAAK;AAET,cAAc;AACd;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,SAASC;IACd,IAAIP,SAASQ,EAAE,KAAK,WAAW;QAC7B,MAAM,IAAIP,oBAAoB,oBAAoB;IACpD;IACA,OAAOC,gBAAgBO,SAAS;AAClC;AAEA,cAAc;AACd;;;;;;;;;;;CAWC,GACD,OAAO,eAAeC;IACpB,IAAI,CAACR,gBAAgBQ,uBAAuB,EAAE;QAC5C,MAAM,IAAIT,oBAAoB,oBAAoB;IACpD;IACA,OAAO,MAAMC,gBAAgBQ,uBAAuB;AACtD;AAEA,cAAc;AACd;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,eAAeC;IACpB,IAAI,CAACT,gBAAgBS,sBAAsB,EAAE;QAC3C,MAAM,IAAIV,oBAAoB,oBAAoB;IACpD;IACA,OAAO,MAAMC,gBAAgBS,sBAAsB;AACrD;AAEA,cAAc;AACd;;;;CAIC,GACD,OAAO,eAAeC;IACpB,IAAI,CAACV,gBAAgBW,8BAA8B,EAAE;QACnD,MAAM,IAAIZ,oBAAoB,oBAAoB;IACpD;IACA,OAAO,MAAMC,gBAAgBW,8BAA8B;AAC7D;AAEA;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,eAAeC;IACpB,IAAI,CAACZ,gBAAgBa,wBAAwB,EAAE;QAC7C,MAAM,IAAId,oBAAoB,oBAAoB;IACpD;IACA,OAAO,MAAMC,gBAAgBa,wBAAwB;AACvD;AAEA,cAAc;AACd;;;;;;CAMC,GACD,OAAO,eAAeC;IACpB,IAAI,CAACd,gBAAgBe,0CAA0C,EAAE;QAC/D,MAAM,IAAIhB,oBAAoB,oBAAoB;IACpD;IACA,OAAO,MAAMC,gBAAgBe,0CAA0C;AACzE;AAEA,cAAc;AACd;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,eAAeC;IACpB,IAAI,CAAChB,gBAAgBgB,wBAAwB,EAAE;QAC7C,MAAM,IAAIjB,oBAAoB,oBAAoB;IACpD;IACA,MAAMkB,mBAAmB,MAAMjB,gBAAgBgB,wBAAwB;IACvE,OAAO,IAAIE,KAAKD;AAClB;AAEA,cAAc;AACd;;;;;;;;;;;CAWC,GACD,OAAO,eAAeE;IACpB,IAAI,CAACnB,gBAAgBmB,sBAAsB,EAAE;QAC3C,MAAM,IAAIpB,oBAAoB,oBAAoB;IACpD;IACA,MAAMqB,iBAAiB,MAAMpB,gBAAgBmB,sBAAsB;IACnE,OAAO,IAAID,KAAKE;AAClB;AAEA,SACEC,sBAAsB,QAGjB,sBAAsB"}
@@ -14,3 +14,19 @@ export declare enum ApplicationReleaseType {
14
14
  * @platform ios
15
15
  */
16
16
  export type PushNotificationServiceEnvironment = 'development' | 'production' | null;
17
+ /**
18
+ * Maps to StoreKit's
19
+ * [`AppStore.Environment`](https://developer.apple.com/documentation/storekit/appstore/environment),
20
+ * as reported by the app's
21
+ * [`AppTransaction.environment`](https://developer.apple.com/documentation/storekit/apptransaction/environment).
22
+ * - `'production'`: An App Store release.
23
+ * - `'sandbox'`: A TestFlight build, a build under App Store Review, or a development, ad hoc, or
24
+ * enterprise-signed build.
25
+ * - `'xcode'`: A build run with a StoreKit configuration file in Xcode.
26
+ * - `null`: StoreKit returns no verified app transaction, or an environment that this version does
27
+ * not recognize. A missing transaction happens on a simulator without a StoreKit configuration
28
+ * file, or when the user is offline or signed out of the App Store before StoreKit caches one.
29
+ * @platform ios
30
+ * @platform tvos
31
+ */
32
+ export type AppleAppStoreEnvironment = 'production' | 'sandbox' | 'xcode' | null;
@@ -4,7 +4,6 @@
4
4
  "modules": ["ApplicationModule"]
5
5
  },
6
6
  "android": {
7
- "modules": ["expo.modules.application.ApplicationModule"],
8
7
  "publication": {
9
8
  "groupId": "host.exp.exponent",
10
9
  "artifactId": "expo.modules.application",
@@ -1,5 +1,6 @@
1
1
  // Copyright 2018-present 650 Industries. All rights reserved.
2
2
  import ExpoModulesCore
3
+ import StoreKit
3
4
 
4
5
  @ExpoModule("ExpoApplication")
5
6
  public class ApplicationModule: Module {
@@ -58,6 +59,27 @@ public class ApplicationModule: Module {
58
59
  return mainProvisioningProfile.appReleaseType().rawValue
59
60
  }
60
61
 
62
+ @JS(.concurrent)
63
+ func getStoreEnvironmentAsync() async -> String? {
64
+ guard case .verified(let transaction) = try? await AppTransaction.shared else {
65
+ return nil
66
+ }
67
+ return Self.storeEnvironment(transaction.environment)
68
+ }
69
+
70
+ static func storeEnvironment(_ environment: AppStore.Environment) -> String? {
71
+ switch environment {
72
+ case .production:
73
+ return "production"
74
+ case .sandbox:
75
+ return "sandbox"
76
+ case .xcode:
77
+ return "xcode"
78
+ default:
79
+ return nil
80
+ }
81
+ }
82
+
61
83
  @JS(.concurrent)
62
84
  func getPushNotificationServiceEnvironmentAsync() async -> String? {
63
85
  let mainProvisioningProfile = EXProvisioningProfile.main()
@@ -35,5 +35,8 @@ Pod::Spec.new do |s|
35
35
  test_spec.dependency 'ExpoModulesTestCore'
36
36
 
37
37
  test_spec.source_files = 'Tests/**/*.{m,swift}'
38
+ # The test bundle links C++ code from ExpoModulesCore but does not inherit its
39
+ # user_target_xcconfig (-lc++), so link the C++ runtime explicitly.
40
+ test_spec.libraries = 'c++'
38
41
  end
39
42
  end
@@ -0,0 +1 @@
1
+ 4e6b197ea81366e4ce706c9bf316457bb0a6dffab7a035f91dbeb4376dd0c6f1
@@ -0,0 +1 @@
1
+ 86e8ef7389ea58be85069e0cc92af6dce9397066c05ff5ef82cbc94319ac21123569e1215983df172e7f8450856e8371f29f311eb4c9258e603f5d9fdb0f07ff
@@ -0,0 +1 @@
1
+ 6c42277423ac93c44f93cb6ffc5b99cbaef685a34694c35df18fea38439991d0
@@ -0,0 +1 @@
1
+ f89769b47863dd16fc59557e328743dbd5e940cbb6a580586b64a52604770f8c9ed27f0573084a9dda31c99da2fe666dbb384320f2bad1aeff7b23cb409cae28
@@ -3,7 +3,7 @@
3
3
  "component": {
4
4
  "group": "host.exp.exponent",
5
5
  "module": "expo.modules.application",
6
- "version": "58.0.3",
6
+ "version": "58.1.0",
7
7
  "attributes": {
8
8
  "org.gradle.status": "release"
9
9
  }
@@ -24,13 +24,13 @@
24
24
  },
25
25
  "files": [
26
26
  {
27
- "name": "expo.modules.application-58.0.3.aar",
28
- "url": "expo.modules.application-58.0.3.aar",
29
- "size": 22526,
30
- "sha512": "bbc7ca518bb2f3e9e426aba12a808376dec2f44f74ea8d8e927e5c505e95bc19dddf5f3fc2efd3035f4a32c37e8e66be22125438374299e0b3ed5924e4b02af7",
31
- "sha256": "65b8ed41cf4e4df7ae98e4be999c41bf11e9d54e37512a9d503ae9d87a24fc28",
32
- "sha1": "a0dc5192265488e4694695bd82f2aff4e92f10b7",
33
- "md5": "0ccb1e544954d9fe2b6744ac25ea402d"
27
+ "name": "expo.modules.application-58.1.0.aar",
28
+ "url": "expo.modules.application-58.1.0.aar",
29
+ "size": 18123,
30
+ "sha512": "f89769b47863dd16fc59557e328743dbd5e940cbb6a580586b64a52604770f8c9ed27f0573084a9dda31c99da2fe666dbb384320f2bad1aeff7b23cb409cae28",
31
+ "sha256": "6c42277423ac93c44f93cb6ffc5b99cbaef685a34694c35df18fea38439991d0",
32
+ "sha1": "ad6b23cd77185c5892195bafa63bff9acff975df",
33
+ "md5": "a9d4d8d15c49e828314a678eccd15bdb"
34
34
  }
35
35
  ]
36
36
  },
@@ -74,13 +74,13 @@
74
74
  ],
75
75
  "files": [
76
76
  {
77
- "name": "expo.modules.application-58.0.3.aar",
78
- "url": "expo.modules.application-58.0.3.aar",
79
- "size": 22526,
80
- "sha512": "bbc7ca518bb2f3e9e426aba12a808376dec2f44f74ea8d8e927e5c505e95bc19dddf5f3fc2efd3035f4a32c37e8e66be22125438374299e0b3ed5924e4b02af7",
81
- "sha256": "65b8ed41cf4e4df7ae98e4be999c41bf11e9d54e37512a9d503ae9d87a24fc28",
82
- "sha1": "a0dc5192265488e4694695bd82f2aff4e92f10b7",
83
- "md5": "0ccb1e544954d9fe2b6744ac25ea402d"
77
+ "name": "expo.modules.application-58.1.0.aar",
78
+ "url": "expo.modules.application-58.1.0.aar",
79
+ "size": 18123,
80
+ "sha512": "f89769b47863dd16fc59557e328743dbd5e940cbb6a580586b64a52604770f8c9ed27f0573084a9dda31c99da2fe666dbb384320f2bad1aeff7b23cb409cae28",
81
+ "sha256": "6c42277423ac93c44f93cb6ffc5b99cbaef685a34694c35df18fea38439991d0",
82
+ "sha1": "ad6b23cd77185c5892195bafa63bff9acff975df",
83
+ "md5": "a9d4d8d15c49e828314a678eccd15bdb"
84
84
  }
85
85
  ]
86
86
  },
@@ -94,13 +94,13 @@
94
94
  },
95
95
  "files": [
96
96
  {
97
- "name": "expo.modules.application-58.0.3-sources.jar",
98
- "url": "expo.modules.application-58.0.3-sources.jar",
99
- "size": 2249,
100
- "sha512": "92aec9238bd78553432160c48fa2a91c68df1c165785a7476d1c54c6a3e81642d67201c8a8c3aad638e1424d70ccbe0a6baac27ec41c3396df592cac5211f2b7",
101
- "sha256": "6f13fc0a916e63b87161bfa61bfdc166fd152ee05ab57530b70e6b2f0aa34459",
102
- "sha1": "3f85782a4a03fac834b261c741dc135cb8475fda",
103
- "md5": "95609cbf50765fa1e2fed16cbe8aa161"
97
+ "name": "expo.modules.application-58.1.0-sources.jar",
98
+ "url": "expo.modules.application-58.1.0-sources.jar",
99
+ "size": 2703,
100
+ "sha512": "86e8ef7389ea58be85069e0cc92af6dce9397066c05ff5ef82cbc94319ac21123569e1215983df172e7f8450856e8371f29f311eb4c9258e603f5d9fdb0f07ff",
101
+ "sha256": "4e6b197ea81366e4ce706c9bf316457bb0a6dffab7a035f91dbeb4376dd0c6f1",
102
+ "sha1": "4d13e39c43a17a2fe848a144d9041eacd70c8a65",
103
+ "md5": "badb9f68537d23227c297015ab75ab33"
104
104
  }
105
105
  ]
106
106
  }
@@ -0,0 +1 @@
1
+ dc8f1a3b74a8e191c06eb967a3c1ca3cb6f70682872dbf0c90b6ebf466182b32
@@ -0,0 +1 @@
1
+ ddae542fb9269d58846983ee76cf94a98a1e2b6220f2cdd2ad36168e1fe637ae6a95c50b7ce9344620f278fa4d9309771b3081991a8f35d42bcebaab9178ebe3
@@ -9,7 +9,7 @@
9
9
  <modelVersion>4.0.0</modelVersion>
10
10
  <groupId>host.exp.exponent</groupId>
11
11
  <artifactId>expo.modules.application</artifactId>
12
- <version>58.0.3</version>
12
+ <version>58.1.0</version>
13
13
  <packaging>aar</packaging>
14
14
  <name>expo.modules.application</name>
15
15
  <url>https://github.com/expo/expo</url>
@@ -0,0 +1 @@
1
+ e42365123c1db953a954e2a0b3a5010823c49065431add165e4cd1c770305e0e
@@ -0,0 +1 @@
1
+ fe2340cf033c78fc332d7ffd2d06d587b8d448a80d8a7e3d5d1121b23aa88a7c5c3a30c333420fb0aa5f230e5bb07cf1717dadef3228e74efae7712b94b60aa1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-application",
3
- "version": "58.0.3",
3
+ "version": "58.1.0",
4
4
  "description": "A universal module that gets native application information such as its ID, app name, and build version at runtime",
5
5
  "keywords": [
6
6
  "expo",
@@ -33,8 +33,9 @@
33
33
  },
34
34
  "dependencies": {},
35
35
  "devDependencies": {
36
- "expo": "58.0.2",
37
- "expo-module-scripts": "56.0.5"
36
+ "@expo/internal-scripts": "58.0.1",
37
+ "expo": "58.0.7",
38
+ "expo-modules-cli": "0.2.1"
38
39
  },
39
40
  "peerDependencies": {
40
41
  "expo": "*"
@@ -48,6 +49,7 @@
48
49
  "swift:format": "../../scripts/swift-format.sh",
49
50
  "swift:lint": "../../scripts/swift-format.sh --lint",
50
51
  "depscheck": "expo-module depscheck",
51
- "typecheck": "tsc -p tsconfig.json"
52
+ "typecheck": "tsc -p tsconfig.json",
53
+ "generate-types": "expo-modules generate-types"
52
54
  }
53
55
  }
@@ -3,6 +3,7 @@ import { Platform, UnavailabilityError } from 'expo';
3
3
  import type {
4
4
  ApplicationReleaseType,
5
5
  PushNotificationServiceEnvironment,
6
+ AppleAppStoreEnvironment,
6
7
  } from './Application.types';
7
8
  import ExpoApplication from './ExpoApplication';
8
9
 
@@ -142,6 +143,30 @@ export async function getIosApplicationReleaseTypeAsync(): Promise<ApplicationRe
142
143
  return await ExpoApplication.getApplicationReleaseTypeAsync();
143
144
  }
144
145
 
146
+ /**
147
+ * Gets the App Store environment of the running build. Unlike
148
+ * [`getIosApplicationReleaseTypeAsync`](#applicationgetiosapplicationreleasetypeasync), which
149
+ * reports `APP_STORE` for both a TestFlight build and an App Store release, this tells them apart.
150
+ * In Expo Go, this reports Expo Go's own environment.
151
+ *
152
+ * @example
153
+ * ```ts
154
+ * if ((await Application.getAppleStoreEnvironmentAsync()) === 'sandbox') {
155
+ * // Show settings for TestFlight testers, App Review and development builds
156
+ * }
157
+ * ```
158
+ * @return A `Promise` which fulfills with an
159
+ * [`AppleAppStoreEnvironment`](#appleappstoreenvironment).
160
+ * @platform ios
161
+ * @platform tvos
162
+ */
163
+ export async function getAppleStoreEnvironmentAsync(): Promise<AppleAppStoreEnvironment> {
164
+ if (!ExpoApplication.getStoreEnvironmentAsync) {
165
+ throw new UnavailabilityError('expo-application', 'getStoreEnvironmentAsync');
166
+ }
167
+ return await ExpoApplication.getStoreEnvironmentAsync();
168
+ }
169
+
145
170
  // @needsAudit
146
171
  /**
147
172
  * Gets the current [Apple Push Notification (APN)](https://developer.apple.com/documentation/bundleresources/entitlements/aps-environment?language=objc)
@@ -207,4 +232,5 @@ export async function getLastUpdateTimeAsync(): Promise<Date> {
207
232
  export {
208
233
  ApplicationReleaseType,
209
234
  type PushNotificationServiceEnvironment,
235
+ type AppleAppStoreEnvironment,
210
236
  } from './Application.types';
@@ -16,3 +16,20 @@ export enum ApplicationReleaseType {
16
16
  * @platform ios
17
17
  */
18
18
  export type PushNotificationServiceEnvironment = 'development' | 'production' | null;
19
+
20
+ /**
21
+ * Maps to StoreKit's
22
+ * [`AppStore.Environment`](https://developer.apple.com/documentation/storekit/appstore/environment),
23
+ * as reported by the app's
24
+ * [`AppTransaction.environment`](https://developer.apple.com/documentation/storekit/apptransaction/environment).
25
+ * - `'production'`: An App Store release.
26
+ * - `'sandbox'`: A TestFlight build, a build under App Store Review, or a development, ad hoc, or
27
+ * enterprise-signed build.
28
+ * - `'xcode'`: A build run with a StoreKit configuration file in Xcode.
29
+ * - `null`: StoreKit returns no verified app transaction, or an environment that this version does
30
+ * not recognize. A missing transaction happens on a simulator without a StoreKit configuration
31
+ * file, or when the user is offline or signed out of the App Store before StoreKit caches one.
32
+ * @platform ios
33
+ * @platform tvos
34
+ */
35
+ export type AppleAppStoreEnvironment = 'production' | 'sandbox' | 'xcode' | null;
@@ -1 +0,0 @@
1
- 6f13fc0a916e63b87161bfa61bfdc166fd152ee05ab57530b70e6b2f0aa34459
@@ -1 +0,0 @@
1
- 92aec9238bd78553432160c48fa2a91c68df1c165785a7476d1c54c6a3e81642d67201c8a8c3aad638e1424d70ccbe0a6baac27ec41c3396df592cac5211f2b7
@@ -1 +0,0 @@
1
- 65b8ed41cf4e4df7ae98e4be999c41bf11e9d54e37512a9d503ae9d87a24fc28
@@ -1 +0,0 @@
1
- bbc7ca518bb2f3e9e426aba12a808376dec2f44f74ea8d8e927e5c505e95bc19dddf5f3fc2efd3035f4a32c37e8e66be22125438374299e0b3ed5924e4b02af7
@@ -1 +0,0 @@
1
- bcbe900a1441a9d344043d789ac45bb7cd6b46282de519a52ee967b1034d5ec9
@@ -1 +0,0 @@
1
- 237698b114a983edcbfb2a7e0c17c813a8217dbbad7132fea0808b1b39c71c1176d48fd11cfe828834b06c0890ab8aa28edc9caa1c2d6c9bf3cd831cd5066f29
@@ -1 +0,0 @@
1
- f5a45767ca36deb18b81c3d6fb6931d060490d7b5aff40982134b39b089d12e3
@@ -1 +0,0 @@
1
- 2bbd24e92f90436d8999f837ebf78209902b5cb42aa4c3832d8c9629f685bb912d46db0ef5d18e8558a4432f1c13adf3f579354551b8b28559f1a44335d995be