expo-cellular 4.0.0 → 4.2.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.
package/CHANGELOG.md CHANGED
@@ -10,6 +10,24 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 4.2.0 — 2022-04-18
14
+
15
+ ### ⚠️ Notices
16
+
17
+ - On Android bump `compileSdkVersion` to `31`, `targetSdkVersion` to `31` and `Java` version to `11`. ([#16941](https://github.com/expo/expo/pull/16941) by [@bbarthec](https://github.com/bbarthec))
18
+
19
+ ## 4.1.1 - 2022-02-01
20
+
21
+ ### 🐛 Bug fixes
22
+
23
+ - Fix `Plugin with id 'maven' not found` build error from Android Gradle 7. ([#16080](https://github.com/expo/expo/pull/16080) by [@kudo](https://github.com/kudo))
24
+
25
+ ## 4.1.0 — 2021-12-03
26
+
27
+ ### 💡 Others
28
+
29
+ - Removed legacy Objective-C implementation and changed the pod name to `ExpoCellular`. ([#15082](https://github.com/expo/expo/pull/15082) by [@tsapeta](https://github.com/tsapeta))
30
+
13
31
  ## 4.0.0 — 2021-09-28
14
32
 
15
33
  ### 🛠 Breaking changes
package/README.md CHANGED
@@ -4,16 +4,16 @@ Information about the user’s cellular service provider, such as its unique ide
4
4
 
5
5
  # API documentation
6
6
 
7
- - [Documentation for the master branch](https://github.com/expo/expo/blob/master/docs/pages/versions/unversioned/sdk/cellular.md)
8
- - [Documentation for the latest stable release](https://docs.expo.io/versions/latest/sdk/cellular/)
7
+ - [Documentation for the main branch](https://github.com/expo/expo/blob/main/docs/pages/versions/unversioned/sdk/cellular.md)
8
+ - [Documentation for the latest stable release](https://docs.expo.dev/versions/latest/sdk/cellular/)
9
9
 
10
10
  # Installation in managed Expo projects
11
11
 
12
- For managed [managed](https://docs.expo.io/versions/latest/introduction/managed-vs-bare/) Expo projects, please follow the installation instructions in the [API documentation for the latest stable release](https://docs.expo.io/versions/latest/sdk/cellular/).
12
+ For [managed](https://docs.expo.dev/versions/latest/introduction/managed-vs-bare/) Expo projects, please follow the installation instructions in the [API documentation for the latest stable release](https://docs.expo.dev/versions/latest/sdk/cellular/).
13
13
 
14
14
  # Installation in bare React Native projects
15
15
 
16
- For bare React Native projects, you must ensure that you have [installed and configured the `react-native-unimodules` package](https://github.com/expo/expo/tree/master/packages/react-native-unimodules) before continuing.
16
+ For bare React Native projects, you must ensure that you have [installed and configured the `expo` package](https://docs.expo.dev/bare/installing-expo-modules/) before continuing.
17
17
 
18
18
  ### Add the package to your npm dependencies
19
19
 
@@ -1,63 +1,80 @@
1
1
  apply plugin: 'com.android.library'
2
2
  apply plugin: 'kotlin-android'
3
- apply plugin: 'maven'
3
+ apply plugin: 'maven-publish'
4
4
 
5
5
  group = 'host.exp.exponent'
6
- version = '4.0.0'
6
+ version = '4.2.0'
7
7
 
8
8
  buildscript {
9
+ def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
10
+ if (expoModulesCorePlugin.exists()) {
11
+ apply from: expoModulesCorePlugin
12
+ applyKotlinExpoModulesCorePlugin()
13
+ }
14
+
9
15
  // Simple helper that allows the root project to override versions declared by this library.
10
16
  ext.safeExtGet = { prop, fallback ->
11
17
  rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
12
18
  }
13
19
 
20
+ // Ensures backward compatibility
21
+ ext.getKotlinVersion = {
22
+ if (ext.has("kotlinVersion")) {
23
+ ext.kotlinVersion()
24
+ } else {
25
+ ext.safeExtGet("kotlinVersion", "1.6.10")
26
+ }
27
+ }
28
+
14
29
  repositories {
15
30
  mavenCentral()
16
31
  }
17
32
 
18
33
  dependencies {
19
- classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${safeExtGet('kotlinVersion', '1.4.21')}")
34
+ classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${getKotlinVersion()}")
20
35
  }
21
36
  }
22
37
 
23
- // Upload android library to maven with javadoc and android sources
24
- configurations {
25
- deployerJars
26
- }
27
-
28
38
  // Creating sources with comments
29
39
  task androidSourcesJar(type: Jar) {
30
40
  classifier = 'sources'
31
41
  from android.sourceSets.main.java.srcDirs
32
42
  }
33
43
 
34
- // Put the androidSources and javadoc to the artifacts
35
- artifacts {
36
- archives androidSourcesJar
37
- }
38
-
39
- uploadArchives {
40
- repositories {
41
- mavenDeployer {
42
- configuration = configurations.deployerJars
43
- repository(url: mavenLocal().url)
44
+ afterEvaluate {
45
+ publishing {
46
+ publications {
47
+ release(MavenPublication) {
48
+ from components.release
49
+ // Add additional sourcesJar to artifacts
50
+ artifact(androidSourcesJar)
51
+ }
52
+ }
53
+ repositories {
54
+ maven {
55
+ url = mavenLocal().url
56
+ }
44
57
  }
45
58
  }
46
59
  }
47
60
 
48
61
  android {
49
- compileSdkVersion safeExtGet("compileSdkVersion", 30)
62
+ compileSdkVersion safeExtGet("compileSdkVersion", 31)
50
63
 
51
64
  compileOptions {
52
- sourceCompatibility JavaVersion.VERSION_1_8
53
- targetCompatibility JavaVersion.VERSION_1_8
65
+ sourceCompatibility JavaVersion.VERSION_11
66
+ targetCompatibility JavaVersion.VERSION_11
67
+ }
68
+
69
+ kotlinOptions {
70
+ jvmTarget = JavaVersion.VERSION_11.majorVersion
54
71
  }
55
72
 
56
73
  defaultConfig {
57
74
  minSdkVersion safeExtGet("minSdkVersion", 21)
58
- targetSdkVersion safeExtGet("targetSdkVersion", 30)
75
+ targetSdkVersion safeExtGet("targetSdkVersion", 31)
59
76
  versionCode 11
60
- versionName '4.0.0'
77
+ versionName '4.2.0'
61
78
  }
62
79
  lintOptions {
63
80
  abortOnError false
@@ -67,5 +84,5 @@ android {
67
84
  dependencies {
68
85
  implementation project(':expo-modules-core')
69
86
 
70
- implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${safeExtGet('kotlinVersion', '1.4.21')}"
87
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}"
71
88
  }
@@ -6,68 +6,62 @@ import android.net.sip.SipManager
6
6
  import android.os.Build
7
7
  import android.telephony.TelephonyManager
8
8
  import android.util.Log
9
- import expo.modules.core.ExportedModule
10
- import expo.modules.core.Promise
11
- import expo.modules.core.interfaces.ExpoMethod
12
- import expo.modules.core.interfaces.RegistryLifecycleListener
13
- import java.util.*
9
+ import expo.modules.kotlin.modules.Module
10
+ import expo.modules.kotlin.modules.ModuleDefinition
14
11
 
15
- class CellularModule(private val mContext: Context) : ExportedModule(mContext), RegistryLifecycleListener {
16
- override fun getName(): String = "ExpoCellular"
12
+ const val moduleName = "ExpoCellular"
17
13
 
18
- private fun telephonyManager() =
19
- (mContext.getSystemService(Context.TELEPHONY_SERVICE) as? TelephonyManager).takeIf {
20
- it?.simState == TelephonyManager.SIM_STATE_READY
14
+ class CellularModule : Module() {
15
+ override fun definition() = ModuleDefinition {
16
+ name(moduleName)
17
+ constants {
18
+ val telephonyManager = telephonyManager()
19
+ mapOf(
20
+ "allowsVoip" to SipManager.isVoipSupported(context),
21
+ "isoCountryCode" to telephonyManager?.simCountryIso,
22
+ "carrier" to telephonyManager?.simOperatorName,
23
+ "mobileCountryCode" to telephonyManager?.simOperator?.substring(0, 3),
24
+ "mobileNetworkCode" to telephonyManager?.simOperator?.substring(3)
25
+ )
21
26
  }
22
27
 
23
- override fun getConstants() =
24
- HashMap<String, Any?>().apply {
25
- val telephonyManager = telephonyManager()
26
- put("allowsVoip", SipManager.isVoipSupported(mContext))
27
- put("isoCountryCode", telephonyManager?.simCountryIso)
28
- put("carrier", telephonyManager?.simOperatorName)
29
- put("mobileCountryCode", telephonyManager?.simOperator?.substring(0, 3))
30
- put("mobileNetworkCode", telephonyManager?.simOperator?.substring(3))
28
+ function("getCellularGenerationAsync") {
29
+ try {
30
+ getCurrentGeneration()
31
+ } catch (e: SecurityException) {
32
+ Log.w(moduleName, "READ_PHONE_STATE permission is required to acquire network type", e)
33
+ CellularGeneration.UNKNOWN.value
34
+ }
31
35
  }
32
36
 
33
- @ExpoMethod
34
- fun getCellularGenerationAsync(promise: Promise) {
35
- try {
36
- promise.resolve(getCurrentGeneration())
37
- } catch (e: SecurityException) {
38
- Log.w(name, "READ_PHONE_STATE permission is required to acquire network type", e)
39
- promise.resolve(CellularGeneration.UNKNOWN.value)
37
+ function("allowsVoipAsync") {
38
+ SipManager.isVoipSupported(context)
40
39
  }
41
- }
42
40
 
43
- @ExpoMethod
44
- fun allowsVoipAsync(promise: Promise) {
45
- promise.resolve(SipManager.isVoipSupported(mContext))
46
- }
41
+ function("getIsoCountryCodeAsync") {
42
+ telephonyManager()?.simCountryIso
43
+ }
47
44
 
48
- @ExpoMethod
49
- fun getIsoCountryCodeAsync(promise: Promise) {
50
- val telephonyManager = telephonyManager()
51
- promise.resolve(telephonyManager?.simCountryIso)
52
- }
45
+ function("getCarrierNameAsync") {
46
+ telephonyManager()?.simOperatorName
47
+ }
53
48
 
54
- @ExpoMethod
55
- fun getCarrierNameAsync(promise: Promise) {
56
- val telephonyManager = telephonyManager()
57
- promise.resolve(telephonyManager?.simOperatorName)
58
- }
49
+ function("getMobileCountryCodeAsync") {
50
+ telephonyManager()?.simOperator?.substring(0, 3)
51
+ }
59
52
 
60
- @ExpoMethod
61
- fun getMobileCountryCodeAsync(promise: Promise) {
62
- val telephonyManager = telephonyManager()
63
- promise.resolve(telephonyManager?.simOperator?.substring(0, 3))
53
+ function("getMobileNetworkCodeAsync") {
54
+ telephonyManager()?.simOperator?.substring(3)
55
+ }
64
56
  }
65
57
 
66
- @ExpoMethod
67
- fun getMobileNetworkCodeAsync(promise: Promise) {
68
- val telephonyManager = telephonyManager()
69
- promise.resolve(telephonyManager?.simOperator?.substring(3))
70
- }
58
+ private fun telephonyManager() =
59
+ (context.getSystemService(Context.TELEPHONY_SERVICE) as? TelephonyManager).takeIf {
60
+ it?.simState == TelephonyManager.SIM_STATE_READY
61
+ }
62
+
63
+ private val context
64
+ get() = requireNotNull(appContext.reactContext)
71
65
 
72
66
  @SuppressLint("MissingPermission")
73
67
  private fun getCurrentGeneration(): Int {
@@ -15,7 +15,7 @@ export { CellularGeneration };
15
15
  * ```ts
16
16
  * Cellular.allowsVoip; // true or false
17
17
  * ```
18
- * @deprecated Deprecated field, use [`allowsVoipAsync()`](#allowsvoipasync) instead.
18
+ * @deprecated Use [`allowsVoipAsync()`](#allowsvoipasync) instead.
19
19
  *
20
20
  */
21
21
  export declare const allowsVoip: boolean | null;
@@ -36,7 +36,7 @@ export declare const allowsVoip: boolean | null;
36
36
  * ```ts
37
37
  * Cellular.carrier; // "T-Mobile" or "Verizon"
38
38
  * ```
39
- * @deprecated Deprecated field, use [`getCarrierNameAsync()`](#getcarriernameasync) instead.
39
+ * @deprecated Use [`getCarrierNameAsync()`](#getcarriernameasync) instead.
40
40
  *
41
41
  */
42
42
  export declare const carrier: string | null;
@@ -53,7 +53,7 @@ export declare const carrier: string | null;
53
53
  * ```ts
54
54
  * Cellular.isoCountryCode; // "us" or "au"
55
55
  * ```
56
- * @deprecated Deprecated field, use [`getIsoCountryCodeAsync()`](#getisocountrycodeAsync) instead.
56
+ * @deprecated Use [`getIsoCountryCodeAsync()`](#getisocountrycodeAsync) instead.
57
57
  *
58
58
  */
59
59
  export declare const isoCountryCode: string | null;
@@ -71,7 +71,7 @@ export declare const isoCountryCode: string | null;
71
71
  * ```ts
72
72
  * Cellular.mobileCountryCode; // "310"
73
73
  * ```
74
- * @deprecated Deprecated field, use [`getMobileCountryCodeAsync()`](#getmobilecountrycodeasync) instead.
74
+ * @deprecated Use [`getMobileCountryCodeAsync()`](#getmobilecountrycodeasync) instead.
75
75
  *
76
76
  */
77
77
  export declare const mobileCountryCode: string | null;
@@ -88,7 +88,7 @@ export declare const mobileCountryCode: string | null;
88
88
  * ```ts
89
89
  * Cellular.mobileNetworkCode; // "260"
90
90
  * ```
91
- * @deprecated Deprecated field, use [`getMobileNetworkCodeAsync()`](#getmobilenetworkcodeasync) instead.
91
+ * @deprecated Use [`getMobileNetworkCodeAsync()`](#getmobilenetworkcodeasync) instead.
92
92
  *
93
93
  */
94
94
  export declare const mobileNetworkCode: string | null;
@@ -196,3 +196,4 @@ export declare function getMobileCountryCodeAsync(): Promise<string | null>;
196
196
  * ```
197
197
  */
198
198
  export declare function getMobileNetworkCodeAsync(): Promise<string | null>;
199
+ //# sourceMappingURL=Cellular.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Cellular.d.ts","sourceRoot":"","sources":["../src/Cellular.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAGtD,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAG9B;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,UAAU,EAAE,OAAO,GAAG,IAAoD,CAAC;AAGxF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,OAAO,EAAE,MAAM,GAAG,IAAiD,CAAC;AAGjF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,cAAc,EAAE,MAAM,GAAG,IAAwD,CAAC;AAG/F;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,iBAAiB,EAAE,MAAM,GAAG,IAEjC,CAAC;AAGT;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,iBAAiB,EAAE,MAAM,GAAG,IAEjC,CAAC;AAGT;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,0BAA0B,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAK9E;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAK/D;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,sBAAsB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAKrE;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAKlE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAKxE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAKxE"}
package/build/Cellular.js CHANGED
@@ -18,7 +18,7 @@ export { CellularGeneration };
18
18
  * ```ts
19
19
  * Cellular.allowsVoip; // true or false
20
20
  * ```
21
- * @deprecated Deprecated field, use [`allowsVoipAsync()`](#allowsvoipasync) instead.
21
+ * @deprecated Use [`allowsVoipAsync()`](#allowsvoipasync) instead.
22
22
  *
23
23
  */
24
24
  export const allowsVoip = ExpoCellular ? ExpoCellular.allowsVoip : null;
@@ -40,7 +40,7 @@ export const allowsVoip = ExpoCellular ? ExpoCellular.allowsVoip : null;
40
40
  * ```ts
41
41
  * Cellular.carrier; // "T-Mobile" or "Verizon"
42
42
  * ```
43
- * @deprecated Deprecated field, use [`getCarrierNameAsync()`](#getcarriernameasync) instead.
43
+ * @deprecated Use [`getCarrierNameAsync()`](#getcarriernameasync) instead.
44
44
  *
45
45
  */
46
46
  export const carrier = ExpoCellular ? ExpoCellular.carrier : null;
@@ -58,7 +58,7 @@ export const carrier = ExpoCellular ? ExpoCellular.carrier : null;
58
58
  * ```ts
59
59
  * Cellular.isoCountryCode; // "us" or "au"
60
60
  * ```
61
- * @deprecated Deprecated field, use [`getIsoCountryCodeAsync()`](#getisocountrycodeAsync) instead.
61
+ * @deprecated Use [`getIsoCountryCodeAsync()`](#getisocountrycodeAsync) instead.
62
62
  *
63
63
  */
64
64
  export const isoCountryCode = ExpoCellular ? ExpoCellular.isoCountryCode : null;
@@ -77,7 +77,7 @@ export const isoCountryCode = ExpoCellular ? ExpoCellular.isoCountryCode : null;
77
77
  * ```ts
78
78
  * Cellular.mobileCountryCode; // "310"
79
79
  * ```
80
- * @deprecated Deprecated field, use [`getMobileCountryCodeAsync()`](#getmobilecountrycodeasync) instead.
80
+ * @deprecated Use [`getMobileCountryCodeAsync()`](#getmobilecountrycodeasync) instead.
81
81
  *
82
82
  */
83
83
  export const mobileCountryCode = ExpoCellular
@@ -97,7 +97,7 @@ export const mobileCountryCode = ExpoCellular
97
97
  * ```ts
98
98
  * Cellular.mobileNetworkCode; // "260"
99
99
  * ```
100
- * @deprecated Deprecated field, use [`getMobileNetworkCodeAsync()`](#getmobilenetworkcodeasync) instead.
100
+ * @deprecated Use [`getMobileNetworkCodeAsync()`](#getmobilenetworkcodeasync) instead.
101
101
  *
102
102
  */
103
103
  export const mobileNetworkCode = ExpoCellular
@@ -1 +1 @@
1
- {"version":3,"file":"Cellular.js","sourceRoot":"","sources":["../src/Cellular.ts"],"names":[],"mappings":"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","sourcesContent":["import { UnavailabilityError } from 'expo-modules-core';\n\nimport { CellularGeneration } from './Cellular.types';\nimport ExpoCellular from './ExpoCellular';\n\nexport { CellularGeneration };\n\n// @needsAudit\n/**\n * Indicates if the carrier allows making VoIP calls on its network. On Android, this checks whether\n * the system supports SIP-based VoIP API. See [here](https://developer.android.com/reference/android/net/sip/SipManager.html#isVoipSupported(android.content.Context))\n * to view more information.\n *\n * On iOS, if you configure a device for a carrier and then remove the SIM card, this property\n * retains the `boolean` value indicating the carrier’s policy regarding VoIP. If you then install\n * a new SIM card, its VoIP policy `boolean` replaces the previous value of this property.\n *\n * On web, this returns `null`.\n *\n * @example\n * ```ts\n * Cellular.allowsVoip; // true or false\n * ```\n * @deprecated Deprecated field, use [`allowsVoipAsync()`](#allowsvoipasync) instead.\n *\n */\nexport const allowsVoip: boolean | null = ExpoCellular ? ExpoCellular.allowsVoip : null;\n\n// @needsAudit\n/**\n * The name of the user’s home cellular service provider. If the device has dual SIM cards, only the\n * carrier for the currently active SIM card will be returned. On Android, this value is only\n * available when the SIM state is [`SIM_STATE_READY`](https://developer.android.com/reference/android/telephony/TelephonyManager.html#SIM_STATE_READY).\n * Otherwise, this returns `null`.\n *\n * On iOS, if you configure a device for a carrier and then remove the SIM card, this property\n * retains the name of the carrier. If you then install a new SIM card, its carrier name replaces\n * the previous value of this property. The value for this property is `null` if the user never\n * configured a carrier for the device.\n *\n * On web, this returns `null`.\n *\n * @example\n * ```ts\n * Cellular.carrier; // \"T-Mobile\" or \"Verizon\"\n * ```\n * @deprecated Deprecated field, use [`getCarrierNameAsync()`](#getcarriernameasync) instead.\n *\n */\nexport const carrier: string | null = ExpoCellular ? ExpoCellular.carrier : null;\n\n// @needsAudit\n/**\n * The ISO country code for the user’s cellular service provider. On iOS, the value is `null` if any\n * of the following apply:\n * - The device is in airplane mode.\n * - There is no SIM card in the device.\n * - The device is outside of cellular service range.\n *\n * On web, this returns `null`.\n *\n * @example\n * ```ts\n * Cellular.isoCountryCode; // \"us\" or \"au\"\n * ```\n * @deprecated Deprecated field, use [`getIsoCountryCodeAsync()`](#getisocountrycodeAsync) instead.\n *\n */\nexport const isoCountryCode: string | null = ExpoCellular ? ExpoCellular.isoCountryCode : null;\n\n// @needsAudit\n/**\n * The mobile country code (MCC) for the user’s current registered cellular service provider.\n * On Android, this value is only available when SIM state is [`SIM_STATE_READY`](https://developer.android.com/reference/android/telephony/TelephonyManager.html#SIM_STATE_READY). Otherwise, this\n * returns `null`. On iOS, the value may be null on hardware prior to iPhone 4S when in airplane mode.\n * Furthermore, the value for this property is `null` if any of the following apply:\n * - There is no SIM card in the device.\n * - The device is outside of cellular service range.\n *\n * On web, this returns `null`.\n *\n * @example\n * ```ts\n * Cellular.mobileCountryCode; // \"310\"\n * ```\n * @deprecated Deprecated field, use [`getMobileCountryCodeAsync()`](#getmobilecountrycodeasync) instead.\n *\n */\nexport const mobileCountryCode: string | null = ExpoCellular\n ? ExpoCellular.mobileCountryCode\n : null;\n\n// @needsAudit\n/**\n * The ISO country code for the user’s cellular service provider. On iOS, the value is `null` if\n * any of the following apply:\n * - The device is in airplane mode.\n * - There is no SIM card in the device.\n * - The device is outside of cellular service range.\n *\n * On web, this returns `null`.\n *\n * @example\n * ```ts\n * Cellular.mobileNetworkCode; // \"260\"\n * ```\n * @deprecated Deprecated field, use [`getMobileNetworkCodeAsync()`](#getmobilenetworkcodeasync) instead.\n *\n */\nexport const mobileNetworkCode: string | null = ExpoCellular\n ? ExpoCellular.mobileNetworkCode\n : null;\n\n// @needsAudit\n/**\n * @return Returns a promise which fulfils with a [`Cellular.CellularGeneration`](#cellulargeneration)\n * enum value that represents the current cellular-generation type.\n *\n * On web, this method uses [`navigator.connection.effectiveType`](https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation/effectiveType)\n * to detect the effective type of the connection using a combination of recently observed\n * round-trip time and downlink values. See [here](https://developer.mozilla.org/en-US/docs/Web/API/Network_Information_API)\n * to view browser compatibility.\n *\n * @example\n * ```ts\n * await Cellular.getCellularGenerationAsync();\n * // CellularGeneration.CELLULAR_4G\n * ```\n */\nexport async function getCellularGenerationAsync(): Promise<CellularGeneration> {\n if (!ExpoCellular.getCellularGenerationAsync) {\n throw new UnavailabilityError('expo-cellular', 'getCellularGenerationAsync');\n }\n return await ExpoCellular.getCellularGenerationAsync();\n}\n\n/**\n * @return Returns if the carrier allows making VoIP calls on its network. On Android, this checks whether\n * the system supports SIP-based VoIP API. See [here](https://developer.android.com/reference/android/net/sip/SipManager.html#isVoipSupported(android.content.Context))\n * to view more information.\n *\n * On iOS, if you configure a device for a carrier and then remove the SIM card, this property\n * retains the `boolean` value indicating the carrier’s policy regarding VoIP. If you then install\n * a new SIM card, its VoIP policy `boolean` replaces the previous value of this property.\n *\n * On web, this returns `null`.\n *\n * @example\n * ```ts\n * await Cellular.allowsVoipAsync(); // true or false\n * ```\n */\nexport async function allowsVoipAsync(): Promise<boolean | null> {\n if (!ExpoCellular.allowsVoipAsync) {\n throw new UnavailabilityError('expo-cellular', 'allowsVoipAsync');\n }\n return await ExpoCellular.allowsVoipAsync();\n}\n\n/**\n * @return Returns the ISO country code for the user’s cellular service provider.\n *\n * On iOS, the value is `null` if any of the following apply:\n * - The device is in airplane mode.\n * - There is no SIM card in the device.\n * - The device is outside of cellular service range.\n *\n * On web, this returns `null`.\n *\n * @example\n * ```ts\n * await Cellular.getIsoCountryCodeAsync(); // \"us\" or \"au\"\n * ```\n *\n */\nexport async function getIsoCountryCodeAsync(): Promise<string | null> {\n if (!ExpoCellular.getIsoCountryCodeAsync) {\n throw new UnavailabilityError('expo-cellular', 'getIsoCountryCodeAsync');\n }\n return await ExpoCellular.getIsoCountryCodeAsync();\n}\n\n/**\n * @return Returns name of the user’s home cellular service provider. If the device has dual SIM cards, only the\n * carrier for the currently active SIM card will be returned.\n *\n * On Android, this value is only available when the SIM state is [`SIM_STATE_READY`](https://developer.android.com/reference/android/telephony/TelephonyManager.html#SIM_STATE_READY).\n * Otherwise, this returns `null`.\n *\n * On iOS, if you configure a device for a carrier and then remove the SIM card, this property\n * retains the name of the carrier. If you then install a new SIM card, its carrier name replaces\n * the previous value of this property. The value for this property is `null` if the user never\n * configured a carrier for the device.\n *\n * On web, this returns `null`.\n *\n * @example\n * ```ts\n * await Cellular.getCarrierNameAsync(); // \"T-Mobile\" or \"Verizon\"\n * ```\n */\nexport async function getCarrierNameAsync(): Promise<string | null> {\n if (!ExpoCellular.getCarrierNameAsync) {\n throw new UnavailabilityError('expo-cellular', 'getCarrierNameAsync');\n }\n return await ExpoCellular.getCarrierNameAsync();\n}\n\n/**\n * @return Returns mobile country code (MCC) for the user’s current registered cellular service provider.\n *\n * On Android, this value is only available when SIM state is [`SIM_STATE_READY`](https://developer.android.com/reference/android/telephony/TelephonyManager.html#SIM_STATE_READY). Otherwise, this\n * returns `null`. On iOS, the value may be null on hardware prior to iPhone 4S when in airplane mode.\n * Furthermore, the value for this property is `null` if any of the following apply:\n * - There is no SIM card in the device.\n * - The device is outside of cellular service range.\n *\n * On web, this returns `null`.\n *\n * @example\n * ```ts\n * await Cellular.getMobileCountryCodeAsync(); // \"310\"\n * ```\n */\nexport async function getMobileCountryCodeAsync(): Promise<string | null> {\n if (!ExpoCellular.getMobileCountryCodeAsync) {\n throw new UnavailabilityError('expo-cellular', 'getMobileCountryCodeAsync');\n }\n return await ExpoCellular.getMobileCountryCodeAsync();\n}\n\n/**\n * @return Returns the mobile network code (MNC) for the user’s current registered cellular service provider.\n *\n * On Android, this value is only available when SIM state is [`SIM_STATE_READY`](https://developer.android.com/reference/android/telephony/TelephonyManager.html#SIM_STATE_READY). Otherwise, this\n * returns `null`. On iOS, the value may be null on hardware prior to iPhone 4S when in airplane mode.\n * Furthermore, the value for this property is `null` if any of the following apply:\n * - There is no SIM card in the device.\n * - The device is outside of cellular service range.\n *\n * On web, this returns `null`.\n *\n * @example\n * ```ts\n * await Cellular.getMobileNetworkCodeAsync(); // \"310\"\n * ```\n */\nexport async function getMobileNetworkCodeAsync(): Promise<string | null> {\n if (!ExpoCellular.getMobileNetworkCodeAsync) {\n throw new UnavailabilityError('expo-cellular', 'getMobileNetworkCodeAsync');\n }\n return await ExpoCellular.getMobileNetworkCodeAsync();\n}\n"]}
1
+ {"version":3,"file":"Cellular.js","sourceRoot":"","sources":["../src/Cellular.ts"],"names":[],"mappings":"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","sourcesContent":["import { UnavailabilityError } from 'expo-modules-core';\n\nimport { CellularGeneration } from './Cellular.types';\nimport ExpoCellular from './ExpoCellular';\n\nexport { CellularGeneration };\n\n// @needsAudit\n/**\n * Indicates if the carrier allows making VoIP calls on its network. On Android, this checks whether\n * the system supports SIP-based VoIP API. See [here](https://developer.android.com/reference/android/net/sip/SipManager.html#isVoipSupported(android.content.Context))\n * to view more information.\n *\n * On iOS, if you configure a device for a carrier and then remove the SIM card, this property\n * retains the `boolean` value indicating the carrier’s policy regarding VoIP. If you then install\n * a new SIM card, its VoIP policy `boolean` replaces the previous value of this property.\n *\n * On web, this returns `null`.\n *\n * @example\n * ```ts\n * Cellular.allowsVoip; // true or false\n * ```\n * @deprecated Use [`allowsVoipAsync()`](#allowsvoipasync) instead.\n *\n */\nexport const allowsVoip: boolean | null = ExpoCellular ? ExpoCellular.allowsVoip : null;\n\n// @needsAudit\n/**\n * The name of the user’s home cellular service provider. If the device has dual SIM cards, only the\n * carrier for the currently active SIM card will be returned. On Android, this value is only\n * available when the SIM state is [`SIM_STATE_READY`](https://developer.android.com/reference/android/telephony/TelephonyManager.html#SIM_STATE_READY).\n * Otherwise, this returns `null`.\n *\n * On iOS, if you configure a device for a carrier and then remove the SIM card, this property\n * retains the name of the carrier. If you then install a new SIM card, its carrier name replaces\n * the previous value of this property. The value for this property is `null` if the user never\n * configured a carrier for the device.\n *\n * On web, this returns `null`.\n *\n * @example\n * ```ts\n * Cellular.carrier; // \"T-Mobile\" or \"Verizon\"\n * ```\n * @deprecated Use [`getCarrierNameAsync()`](#getcarriernameasync) instead.\n *\n */\nexport const carrier: string | null = ExpoCellular ? ExpoCellular.carrier : null;\n\n// @needsAudit\n/**\n * The ISO country code for the user’s cellular service provider. On iOS, the value is `null` if any\n * of the following apply:\n * - The device is in airplane mode.\n * - There is no SIM card in the device.\n * - The device is outside of cellular service range.\n *\n * On web, this returns `null`.\n *\n * @example\n * ```ts\n * Cellular.isoCountryCode; // \"us\" or \"au\"\n * ```\n * @deprecated Use [`getIsoCountryCodeAsync()`](#getisocountrycodeAsync) instead.\n *\n */\nexport const isoCountryCode: string | null = ExpoCellular ? ExpoCellular.isoCountryCode : null;\n\n// @needsAudit\n/**\n * The mobile country code (MCC) for the user’s current registered cellular service provider.\n * On Android, this value is only available when SIM state is [`SIM_STATE_READY`](https://developer.android.com/reference/android/telephony/TelephonyManager.html#SIM_STATE_READY). Otherwise, this\n * returns `null`. On iOS, the value may be null on hardware prior to iPhone 4S when in airplane mode.\n * Furthermore, the value for this property is `null` if any of the following apply:\n * - There is no SIM card in the device.\n * - The device is outside of cellular service range.\n *\n * On web, this returns `null`.\n *\n * @example\n * ```ts\n * Cellular.mobileCountryCode; // \"310\"\n * ```\n * @deprecated Use [`getMobileCountryCodeAsync()`](#getmobilecountrycodeasync) instead.\n *\n */\nexport const mobileCountryCode: string | null = ExpoCellular\n ? ExpoCellular.mobileCountryCode\n : null;\n\n// @needsAudit\n/**\n * The ISO country code for the user’s cellular service provider. On iOS, the value is `null` if\n * any of the following apply:\n * - The device is in airplane mode.\n * - There is no SIM card in the device.\n * - The device is outside of cellular service range.\n *\n * On web, this returns `null`.\n *\n * @example\n * ```ts\n * Cellular.mobileNetworkCode; // \"260\"\n * ```\n * @deprecated Use [`getMobileNetworkCodeAsync()`](#getmobilenetworkcodeasync) instead.\n *\n */\nexport const mobileNetworkCode: string | null = ExpoCellular\n ? ExpoCellular.mobileNetworkCode\n : null;\n\n// @needsAudit\n/**\n * @return Returns a promise which fulfils with a [`Cellular.CellularGeneration`](#cellulargeneration)\n * enum value that represents the current cellular-generation type.\n *\n * On web, this method uses [`navigator.connection.effectiveType`](https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation/effectiveType)\n * to detect the effective type of the connection using a combination of recently observed\n * round-trip time and downlink values. See [here](https://developer.mozilla.org/en-US/docs/Web/API/Network_Information_API)\n * to view browser compatibility.\n *\n * @example\n * ```ts\n * await Cellular.getCellularGenerationAsync();\n * // CellularGeneration.CELLULAR_4G\n * ```\n */\nexport async function getCellularGenerationAsync(): Promise<CellularGeneration> {\n if (!ExpoCellular.getCellularGenerationAsync) {\n throw new UnavailabilityError('expo-cellular', 'getCellularGenerationAsync');\n }\n return await ExpoCellular.getCellularGenerationAsync();\n}\n\n/**\n * @return Returns if the carrier allows making VoIP calls on its network. On Android, this checks whether\n * the system supports SIP-based VoIP API. See [here](https://developer.android.com/reference/android/net/sip/SipManager.html#isVoipSupported(android.content.Context))\n * to view more information.\n *\n * On iOS, if you configure a device for a carrier and then remove the SIM card, this property\n * retains the `boolean` value indicating the carrier’s policy regarding VoIP. If you then install\n * a new SIM card, its VoIP policy `boolean` replaces the previous value of this property.\n *\n * On web, this returns `null`.\n *\n * @example\n * ```ts\n * await Cellular.allowsVoipAsync(); // true or false\n * ```\n */\nexport async function allowsVoipAsync(): Promise<boolean | null> {\n if (!ExpoCellular.allowsVoipAsync) {\n throw new UnavailabilityError('expo-cellular', 'allowsVoipAsync');\n }\n return await ExpoCellular.allowsVoipAsync();\n}\n\n/**\n * @return Returns the ISO country code for the user’s cellular service provider.\n *\n * On iOS, the value is `null` if any of the following apply:\n * - The device is in airplane mode.\n * - There is no SIM card in the device.\n * - The device is outside of cellular service range.\n *\n * On web, this returns `null`.\n *\n * @example\n * ```ts\n * await Cellular.getIsoCountryCodeAsync(); // \"us\" or \"au\"\n * ```\n *\n */\nexport async function getIsoCountryCodeAsync(): Promise<string | null> {\n if (!ExpoCellular.getIsoCountryCodeAsync) {\n throw new UnavailabilityError('expo-cellular', 'getIsoCountryCodeAsync');\n }\n return await ExpoCellular.getIsoCountryCodeAsync();\n}\n\n/**\n * @return Returns name of the user’s home cellular service provider. If the device has dual SIM cards, only the\n * carrier for the currently active SIM card will be returned.\n *\n * On Android, this value is only available when the SIM state is [`SIM_STATE_READY`](https://developer.android.com/reference/android/telephony/TelephonyManager.html#SIM_STATE_READY).\n * Otherwise, this returns `null`.\n *\n * On iOS, if you configure a device for a carrier and then remove the SIM card, this property\n * retains the name of the carrier. If you then install a new SIM card, its carrier name replaces\n * the previous value of this property. The value for this property is `null` if the user never\n * configured a carrier for the device.\n *\n * On web, this returns `null`.\n *\n * @example\n * ```ts\n * await Cellular.getCarrierNameAsync(); // \"T-Mobile\" or \"Verizon\"\n * ```\n */\nexport async function getCarrierNameAsync(): Promise<string | null> {\n if (!ExpoCellular.getCarrierNameAsync) {\n throw new UnavailabilityError('expo-cellular', 'getCarrierNameAsync');\n }\n return await ExpoCellular.getCarrierNameAsync();\n}\n\n/**\n * @return Returns mobile country code (MCC) for the user’s current registered cellular service provider.\n *\n * On Android, this value is only available when SIM state is [`SIM_STATE_READY`](https://developer.android.com/reference/android/telephony/TelephonyManager.html#SIM_STATE_READY). Otherwise, this\n * returns `null`. On iOS, the value may be null on hardware prior to iPhone 4S when in airplane mode.\n * Furthermore, the value for this property is `null` if any of the following apply:\n * - There is no SIM card in the device.\n * - The device is outside of cellular service range.\n *\n * On web, this returns `null`.\n *\n * @example\n * ```ts\n * await Cellular.getMobileCountryCodeAsync(); // \"310\"\n * ```\n */\nexport async function getMobileCountryCodeAsync(): Promise<string | null> {\n if (!ExpoCellular.getMobileCountryCodeAsync) {\n throw new UnavailabilityError('expo-cellular', 'getMobileCountryCodeAsync');\n }\n return await ExpoCellular.getMobileCountryCodeAsync();\n}\n\n/**\n * @return Returns the mobile network code (MNC) for the user’s current registered cellular service provider.\n *\n * On Android, this value is only available when SIM state is [`SIM_STATE_READY`](https://developer.android.com/reference/android/telephony/TelephonyManager.html#SIM_STATE_READY). Otherwise, this\n * returns `null`. On iOS, the value may be null on hardware prior to iPhone 4S when in airplane mode.\n * Furthermore, the value for this property is `null` if any of the following apply:\n * - There is no SIM card in the device.\n * - The device is outside of cellular service range.\n *\n * On web, this returns `null`.\n *\n * @example\n * ```ts\n * await Cellular.getMobileNetworkCodeAsync(); // \"310\"\n * ```\n */\nexport async function getMobileNetworkCodeAsync(): Promise<string | null> {\n if (!ExpoCellular.getMobileNetworkCodeAsync) {\n throw new UnavailabilityError('expo-cellular', 'getMobileNetworkCodeAsync');\n }\n return await ExpoCellular.getMobileNetworkCodeAsync();\n}\n"]}
@@ -24,3 +24,4 @@ export declare enum CellularGeneration {
24
24
  */
25
25
  CELLULAR_5G = 4
26
26
  }
27
+ //# sourceMappingURL=Cellular.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Cellular.types.d.ts","sourceRoot":"","sources":["../src/Cellular.types.ts"],"names":[],"mappings":"AACA;;;GAGG;AACH,oBAAY,kBAAkB;IAC5B;;OAEG;IACH,OAAO,IAAI;IACX;;OAEG;IACH,WAAW,IAAI;IACf;;OAEG;IACH,WAAW,IAAI;IACf;;OAEG;IACH,WAAW,IAAI;IACf;;OAEG;IACH,WAAW,IAAI;CAChB"}
@@ -1,2 +1,3 @@
1
1
  declare const _default: import("expo-modules-core").ProxyNativeModule;
2
2
  export default _default;
3
+ //# sourceMappingURL=ExpoCellular.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExpoCellular.d.ts","sourceRoot":"","sources":["../src/ExpoCellular.ts"],"names":[],"mappings":";AACA,wBAA+C"}
@@ -13,3 +13,4 @@ declare const _default: {
13
13
  getMobileNetworkCodeAsync(): Promise<string | null>;
14
14
  };
15
15
  export default _default;
16
+ //# sourceMappingURL=ExpoCellular.web.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExpoCellular.web.d.ts","sourceRoot":"","sources":["../src/ExpoCellular.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;;;;;;;kCAkBhB,QAAQ,kBAAkB,CAAC;uBAoBtC,QAAQ,OAAO,GAAG,IAAI,CAAC;8BAGhB,QAAQ,MAAM,GAAG,IAAI,CAAC;2BAGzB,QAAQ,MAAM,GAAG,IAAI,CAAC;iCAGhB,QAAQ,MAAM,GAAG,IAAI,CAAC;iCAGtB,QAAQ,MAAM,GAAG,IAAI,CAAC;;AAhD3D,wBAmDE"}
@@ -16,10 +16,7 @@ export default {
16
16
  return null;
17
17
  },
18
18
  async getCellularGenerationAsync() {
19
- const connection = navigator['connection'] ||
20
- navigator['mozConnection'] ||
21
- navigator['webkitConnection'] ||
22
- null;
19
+ const connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection || null;
23
20
  if (connection !== null) {
24
21
  switch (connection.effectiveType) {
25
22
  case 'slow-2g':
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoCellular.web.js","sourceRoot":"","sources":["../src/ExpoCellular.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,eAAe;IACb,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,OAAO;QACT,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,cAAc;QAChB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,iBAAiB;QACnB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,iBAAiB;QACnB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,KAAK,CAAC,0BAA0B;QAC9B,MAAM,UAAU,GACd,SAAS,CAAC,YAAY,CAAC;YACvB,SAAS,CAAC,eAAe,CAAC;YAC1B,SAAS,CAAC,kBAAkB,CAAC;YAC7B,IAAI,CAAC;QACP,IAAI,UAAU,KAAK,IAAI,EAAE;YACvB,QAAQ,UAAU,CAAC,aAAa,EAAE;gBAChC,KAAK,SAAS,CAAC;gBACf,KAAK,IAAI;oBACP,OAAO,kBAAkB,CAAC,WAAW,CAAC;gBACxC,KAAK,IAAI;oBACP,OAAO,kBAAkB,CAAC,WAAW,CAAC;gBACxC,KAAK,IAAI;oBACP,OAAO,kBAAkB,CAAC,WAAW,CAAC;gBACxC;oBACE,OAAO,kBAAkB,CAAC,OAAO,CAAC;aACrC;SACF;aAAM;YACL,OAAO,kBAAkB,CAAC,OAAO,CAAC;SACnC;IACH,CAAC;IAED,KAAK,CAAC,eAAe;QACnB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,KAAK,CAAC,sBAAsB;QAC1B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,KAAK,CAAC,mBAAmB;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,KAAK,CAAC,yBAAyB;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,KAAK,CAAC,yBAAyB;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAC","sourcesContent":["import { CellularGeneration } from './Cellular.types';\n\nexport default {\n get allowsVoip(): null {\n return null;\n },\n get carrier(): null {\n return null;\n },\n get isoCountryCode(): null {\n return null;\n },\n get mobileCountryCode(): null {\n return null;\n },\n get mobileNetworkCode(): null {\n return null;\n },\n async getCellularGenerationAsync(): Promise<CellularGeneration> {\n const connection =\n navigator['connection'] ||\n navigator['mozConnection'] ||\n navigator['webkitConnection'] ||\n null;\n if (connection !== null) {\n switch (connection.effectiveType) {\n case 'slow-2g':\n case '2g':\n return CellularGeneration.CELLULAR_2G;\n case '3g':\n return CellularGeneration.CELLULAR_3G;\n case '4g':\n return CellularGeneration.CELLULAR_4G;\n default:\n return CellularGeneration.UNKNOWN;\n }\n } else {\n return CellularGeneration.UNKNOWN;\n }\n },\n\n async allowsVoipAsync(): Promise<boolean | null> {\n return null;\n },\n async getIsoCountryCodeAsync(): Promise<string | null> {\n return null;\n },\n async getCarrierNameAsync(): Promise<string | null> {\n return null;\n },\n async getMobileCountryCodeAsync(): Promise<string | null> {\n return null;\n },\n async getMobileNetworkCodeAsync(): Promise<string | null> {\n return null;\n },\n};\n"]}
1
+ {"version":3,"file":"ExpoCellular.web.js","sourceRoot":"","sources":["../src/ExpoCellular.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,eAAe;IACb,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,OAAO;QACT,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,cAAc;QAChB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,iBAAiB;QACnB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,iBAAiB;QACnB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,KAAK,CAAC,0BAA0B;QAC9B,MAAM,UAAU,GACd,SAAS,CAAC,UAAU,IAAI,SAAS,CAAC,aAAa,IAAI,SAAS,CAAC,gBAAgB,IAAI,IAAI,CAAC;QACxF,IAAI,UAAU,KAAK,IAAI,EAAE;YACvB,QAAQ,UAAU,CAAC,aAAa,EAAE;gBAChC,KAAK,SAAS,CAAC;gBACf,KAAK,IAAI;oBACP,OAAO,kBAAkB,CAAC,WAAW,CAAC;gBACxC,KAAK,IAAI;oBACP,OAAO,kBAAkB,CAAC,WAAW,CAAC;gBACxC,KAAK,IAAI;oBACP,OAAO,kBAAkB,CAAC,WAAW,CAAC;gBACxC;oBACE,OAAO,kBAAkB,CAAC,OAAO,CAAC;aACrC;SACF;aAAM;YACL,OAAO,kBAAkB,CAAC,OAAO,CAAC;SACnC;IACH,CAAC;IAED,KAAK,CAAC,eAAe;QACnB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,KAAK,CAAC,sBAAsB;QAC1B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,KAAK,CAAC,mBAAmB;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,KAAK,CAAC,yBAAyB;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,KAAK,CAAC,yBAAyB;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAC","sourcesContent":["import { CellularGeneration } from './Cellular.types';\n\nexport default {\n get allowsVoip(): null {\n return null;\n },\n get carrier(): null {\n return null;\n },\n get isoCountryCode(): null {\n return null;\n },\n get mobileCountryCode(): null {\n return null;\n },\n get mobileNetworkCode(): null {\n return null;\n },\n async getCellularGenerationAsync(): Promise<CellularGeneration> {\n const connection =\n navigator.connection || navigator.mozConnection || navigator.webkitConnection || null;\n if (connection !== null) {\n switch (connection.effectiveType) {\n case 'slow-2g':\n case '2g':\n return CellularGeneration.CELLULAR_2G;\n case '3g':\n return CellularGeneration.CELLULAR_3G;\n case '4g':\n return CellularGeneration.CELLULAR_4G;\n default:\n return CellularGeneration.UNKNOWN;\n }\n } else {\n return CellularGeneration.UNKNOWN;\n }\n },\n\n async allowsVoipAsync(): Promise<boolean | null> {\n return null;\n },\n async getIsoCountryCodeAsync(): Promise<string | null> {\n return null;\n },\n async getCarrierNameAsync(): Promise<string | null> {\n return null;\n },\n async getMobileCountryCodeAsync(): Promise<string | null> {\n return null;\n },\n async getMobileNetworkCodeAsync(): Promise<string | null> {\n return null;\n },\n};\n"]}
@@ -3,5 +3,8 @@
3
3
  "platforms": ["ios", "android", "web"],
4
4
  "ios": {
5
5
  "modulesClassNames": ["CellularModule"]
6
+ },
7
+ "android": {
8
+ "modulesClassNames": ["expo.modules.cellular.CellularModule"]
6
9
  }
7
10
  }
@@ -4,25 +4,32 @@ import ExpoModulesCore
4
4
  public class CellularModule: Module {
5
5
  public func definition() -> ModuleDefinition {
6
6
  name("ExpoCellular")
7
+
7
8
  constants {
8
9
  Self.getCurrentCellularInfo()
9
10
  }
10
- method("getCellularGenerationAsync") { () -> Int in
11
+
12
+ function("getCellularGenerationAsync") { () -> Int in
11
13
  Self.currentCellularGeneration().rawValue
12
14
  }
13
- method("allowsVoipAsync") { () -> Bool? in
15
+
16
+ function("allowsVoipAsync") { () -> Bool? in
14
17
  Self.currentCarrier()?.allowsVOIP
15
18
  }
16
- method("getIsoCountryCodeAsync") { () -> String? in
19
+
20
+ function("getIsoCountryCodeAsync") { () -> String? in
17
21
  Self.currentCarrier()?.isoCountryCode
18
22
  }
19
- method("getCarrierNameAsync") { () -> String? in
23
+
24
+ function("getCarrierNameAsync") { () -> String? in
20
25
  Self.currentCarrier()?.carrierName
21
26
  }
22
- method("getMobileCountryCodeAsync") { () -> String? in
27
+
28
+ function("getMobileCountryCodeAsync") { () -> String? in
23
29
  Self.currentCarrier()?.mobileCountryCode
24
30
  }
25
- method("getMobileNetworkCodeAsync") { () -> String? in
31
+
32
+ function("getMobileNetworkCodeAsync") { () -> String? in
26
33
  Self.currentCarrier()?.mobileNetworkCode
27
34
  }
28
35
  }
@@ -60,8 +67,8 @@ public class CellularModule: Module {
60
67
  return .cellular4G
61
68
  default:
62
69
  if #available(iOS 14.1, *) {
63
- if (radioAccessTechnology == CTRadioAccessTechnologyNRNSA ||
64
- radioAccessTechnology == CTRadioAccessTechnologyNR) {
70
+ if radioAccessTechnology == CTRadioAccessTechnologyNRNSA ||
71
+ radioAccessTechnology == CTRadioAccessTechnologyNR {
65
72
  return .cellular5G
66
73
  }
67
74
  }
@@ -69,7 +76,7 @@ public class CellularModule: Module {
69
76
  }
70
77
  }
71
78
 
72
- static func getCurrentCellularInfo() -> [String : Any?] {
79
+ static func getCurrentCellularInfo() -> [String: Any?] {
73
80
  let carrier = Self.currentCarrier()
74
81
  let generation = Self.currentCellularGeneration()
75
82
 
@@ -79,7 +86,7 @@ public class CellularModule: Module {
79
86
  "isoCountryCode": carrier?.isoCountryCode,
80
87
  "mobileCountryCode": carrier?.mobileCountryCode,
81
88
  "mobileNetworkCode": carrier?.mobileNetworkCode,
82
- "generation": generation.rawValue,
89
+ "generation": generation.rawValue
83
90
  ]
84
91
  }
85
92
 
@@ -97,10 +104,8 @@ public class CellularModule: Module {
97
104
  let netinfo = CTTelephonyNetworkInfo()
98
105
 
99
106
  if #available(iOS 12.0, *), let providers = netinfo.serviceSubscriberCellularProviders {
100
- for carrier in providers.values {
101
- if carrier.carrierName != nil {
102
- return carrier
103
- }
107
+ for carrier in providers.values where carrier.carrierName != nil {
108
+ return carrier
104
109
  }
105
110
  return providers.values.first
106
111
  }
@@ -3,7 +3,7 @@ require 'json'
3
3
  package = JSON.parse(File.read(File.join(__dir__, '..', 'package.json')))
4
4
 
5
5
  Pod::Spec.new do |s|
6
- s.name = 'EXCellular'
6
+ s.name = 'ExpoCellular'
7
7
  s.version = package['version']
8
8
  s.summary = package['description']
9
9
  s.description = package['description']
@@ -19,13 +19,14 @@ Pod::Spec.new do |s|
19
19
 
20
20
  # Swift/Objective-C compatibility
21
21
  s.pod_target_xcconfig = {
22
- 'DEFINES_MODULE' => 'YES'
22
+ 'DEFINES_MODULE' => 'YES',
23
+ 'SWIFT_COMPILATION_MODE' => 'wholemodule'
23
24
  }
24
25
 
25
26
  if !$ExpoUseSources&.include?(package['name']) && ENV['EXPO_USE_SOURCE'].to_i == 0 && File.exist?("#{s.name}.xcframework") && Gem::Version.new(Pod::VERSION) >= Gem::Version.new('1.10.0')
26
- s.source_files = "#{s.name}/**/*.h"
27
+ s.source_files = "**/*.h"
27
28
  s.vendored_frameworks = "#{s.name}.xcframework"
28
29
  else
29
- s.source_files = "#{s.name}/**/*.{h,m,swift}"
30
+ s.source_files = "**/*.{h,m,swift}"
30
31
  end
31
32
  end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-cellular",
3
- "version": "4.0.0",
3
+ "version": "4.2.0",
4
4
  "description": "Provides information about the user’s cellular service provider",
5
5
  "main": "build/Cellular.js",
6
6
  "types": "build/Cellular.d.ts",
@@ -29,8 +29,12 @@
29
29
  "author": "650 Industries, Inc.",
30
30
  "license": "MIT",
31
31
  "homepage": "https://docs.expo.dev/versions/latest/sdk/cellular/",
32
+ "dependencies": {},
32
33
  "devDependencies": {
33
34
  "expo-module-scripts": "^2.0.0"
34
35
  },
35
- "gitHead": "1fffde73411ee7a642b98f1506a8de921805d52b"
36
+ "peerDependencies": {
37
+ "expo": "*"
38
+ },
39
+ "gitHead": "89a27c0ca0ca8becd7546697298e874a15e94faf"
36
40
  }
@@ -9,4 +9,4 @@ const withCellular = (config) => {
9
9
  ]);
10
10
  return config;
11
11
  };
12
- exports.default = config_plugins_1.createRunOncePlugin(withCellular, pkg.name, pkg.version);
12
+ exports.default = (0, config_plugins_1.createRunOncePlugin)(withCellular, pkg.name, pkg.version);
package/src/Cellular.ts CHANGED
@@ -21,7 +21,7 @@ export { CellularGeneration };
21
21
  * ```ts
22
22
  * Cellular.allowsVoip; // true or false
23
23
  * ```
24
- * @deprecated Deprecated field, use [`allowsVoipAsync()`](#allowsvoipasync) instead.
24
+ * @deprecated Use [`allowsVoipAsync()`](#allowsvoipasync) instead.
25
25
  *
26
26
  */
27
27
  export const allowsVoip: boolean | null = ExpoCellular ? ExpoCellular.allowsVoip : null;
@@ -44,7 +44,7 @@ export const allowsVoip: boolean | null = ExpoCellular ? ExpoCellular.allowsVoip
44
44
  * ```ts
45
45
  * Cellular.carrier; // "T-Mobile" or "Verizon"
46
46
  * ```
47
- * @deprecated Deprecated field, use [`getCarrierNameAsync()`](#getcarriernameasync) instead.
47
+ * @deprecated Use [`getCarrierNameAsync()`](#getcarriernameasync) instead.
48
48
  *
49
49
  */
50
50
  export const carrier: string | null = ExpoCellular ? ExpoCellular.carrier : null;
@@ -63,7 +63,7 @@ export const carrier: string | null = ExpoCellular ? ExpoCellular.carrier : null
63
63
  * ```ts
64
64
  * Cellular.isoCountryCode; // "us" or "au"
65
65
  * ```
66
- * @deprecated Deprecated field, use [`getIsoCountryCodeAsync()`](#getisocountrycodeAsync) instead.
66
+ * @deprecated Use [`getIsoCountryCodeAsync()`](#getisocountrycodeAsync) instead.
67
67
  *
68
68
  */
69
69
  export const isoCountryCode: string | null = ExpoCellular ? ExpoCellular.isoCountryCode : null;
@@ -83,7 +83,7 @@ export const isoCountryCode: string | null = ExpoCellular ? ExpoCellular.isoCoun
83
83
  * ```ts
84
84
  * Cellular.mobileCountryCode; // "310"
85
85
  * ```
86
- * @deprecated Deprecated field, use [`getMobileCountryCodeAsync()`](#getmobilecountrycodeasync) instead.
86
+ * @deprecated Use [`getMobileCountryCodeAsync()`](#getmobilecountrycodeasync) instead.
87
87
  *
88
88
  */
89
89
  export const mobileCountryCode: string | null = ExpoCellular
@@ -104,7 +104,7 @@ export const mobileCountryCode: string | null = ExpoCellular
104
104
  * ```ts
105
105
  * Cellular.mobileNetworkCode; // "260"
106
106
  * ```
107
- * @deprecated Deprecated field, use [`getMobileNetworkCodeAsync()`](#getmobilenetworkcodeasync) instead.
107
+ * @deprecated Use [`getMobileNetworkCodeAsync()`](#getmobilenetworkcodeasync) instead.
108
108
  *
109
109
  */
110
110
  export const mobileNetworkCode: string | null = ExpoCellular
@@ -18,10 +18,7 @@ export default {
18
18
  },
19
19
  async getCellularGenerationAsync(): Promise<CellularGeneration> {
20
20
  const connection =
21
- navigator['connection'] ||
22
- navigator['mozConnection'] ||
23
- navigator['webkitConnection'] ||
24
- null;
21
+ navigator.connection || navigator.mozConnection || navigator.webkitConnection || null;
25
22
  if (connection !== null) {
26
23
  switch (connection.effectiveType) {
27
24
  case 'slow-2g':
@@ -0,0 +1,18 @@
1
+ // Expose this file as a module (see https://stackoverflow.com/a/59499895/4337317)
2
+ export {};
3
+
4
+ /**
5
+ * Handle deprecations and missing typings that not available in the main lib.dom.d.ts file.
6
+ */
7
+ declare global {
8
+ type EffectiveConnectionType = '2g' | '3g' | '4g' | 'slow-2g';
9
+
10
+ interface NetworkInformation {
11
+ readonly effectiveType: EffectiveConnectionType;
12
+ }
13
+
14
+ interface Navigator {
15
+ readonly mozConnection?: NetworkInformation;
16
+ readonly webkitConnection?: NetworkInformation;
17
+ }
18
+ }
@@ -1,9 +0,0 @@
1
- package expo.modules.cellular
2
-
3
- import android.content.Context
4
- import expo.modules.core.BasePackage
5
-
6
- class CellularPackage : BasePackage() {
7
- override fun createExportedModules(context: Context) =
8
- listOf(CellularModule(context))
9
- }
@@ -1,23 +0,0 @@
1
- // Copyright © 2018 650 Industries. All rights reserved.
2
-
3
- #import <ExpoModulesCore/EXExportedModule.h>
4
- #import <ExpoModulesCore/EXModuleRegistryConsumer.h>
5
-
6
- NS_ASSUME_NONNULL_BEGIN
7
-
8
- // Keep this enum in sync with JavaScript
9
- // Based on the EffectiveConnectionType enum described in the W3C Network Information API spec
10
- // (https://wicg.github.io/netinfo/).
11
- typedef NS_ENUM(NSInteger, EXCellularGeneration) {
12
- EXCellularGenerationUnknown = 0,
13
- EXCellularGeneration2G,
14
- EXCellularGeneration3G,
15
- EXCellularGeneration4G,
16
- EXCellularGeneration5G,
17
- };
18
-
19
- @interface EXCellularModule : EXExportedModule <EXModuleRegistryConsumer>
20
-
21
- @end
22
-
23
- NS_ASSUME_NONNULL_END
@@ -1,153 +0,0 @@
1
- // Copyright 2018-present 650 Industries. All rights reserved.
2
-
3
- #import <EXCellular/EXCellularModule.h>
4
-
5
- #import <CoreTelephony/CTCarrier.h>
6
- #import <CoreTelephony/CTTelephonyNetworkInfo.h>
7
-
8
-
9
- @interface EXCellularModule ()
10
-
11
- @property (nonatomic, weak) EXModuleRegistry *moduleRegistry;
12
-
13
- @end
14
-
15
- @implementation EXCellularModule
16
-
17
- EX_EXPORT_MODULE(ExpoCellular);
18
-
19
- - (void)setModuleRegistry:(EXModuleRegistry *)moduleRegistry
20
- {
21
- _moduleRegistry = moduleRegistry;
22
- }
23
-
24
- - (NSDictionary *)constantsToExport
25
- {
26
- CTCarrier *carrier = [self carrier];
27
-
28
- return [self getCurrentCellularInfo];
29
- }
30
-
31
- EX_EXPORT_METHOD_AS(getCellularGenerationAsync, getCellularGenerationAsyncWithResolver:(EXPromiseResolveBlock)resolve rejecter:(EXPromiseRejectBlock)reject)
32
- {
33
- resolve(@([[self class] getCellularGeneration]));
34
- }
35
-
36
- EX_EXPORT_METHOD_AS(allowsVoipAsync, allowsVoipAsyncWithResolver:(EXPromiseResolveBlock)resolve rejecter:(EXPromiseRejectBlock)reject)
37
- {
38
- resolve(@([self allowsVoip]));
39
- }
40
-
41
- EX_EXPORT_METHOD_AS(getIsoCountryCodeAsync, getIsoCountryCodeAsyncWithResolver:(EXPromiseResolveBlock)resolve rejecter:(EXPromiseRejectBlock)reject)
42
- {
43
- resolve([self getIsoCountryCode]);
44
- }
45
-
46
- EX_EXPORT_METHOD_AS(getCarrierNameAsync, getCarrierNameAsyncWithResolver:(EXPromiseResolveBlock)resolve rejecter:(EXPromiseRejectBlock)reject)
47
- {
48
- resolve([self getCarrierName]);
49
- }
50
-
51
- EX_EXPORT_METHOD_AS(getMobileCountryCodeAsync, getMobileCountryCodeAsyncWithResolver:(EXPromiseResolveBlock)resolve rejecter:(EXPromiseRejectBlock)reject)
52
- {
53
- resolve([self getMobileCountryCode]);
54
- }
55
-
56
- EX_EXPORT_METHOD_AS(getMobileNetworkCodeAsync, getMobileNetworkCodeAsyncWithResolver:(EXPromiseResolveBlock)resolve rejecter:(EXPromiseRejectBlock)reject)
57
- {
58
- resolve([self getMobileNetworkCode]);
59
- }
60
-
61
- + (EXCellularGeneration)getCellularGeneration
62
- {
63
- CTTelephonyNetworkInfo *netinfo = [[CTTelephonyNetworkInfo alloc] init];
64
- NSString *serviceCurrentRadioAccessTechnology;
65
- if (@available(iOS 12.0, *)) {
66
- serviceCurrentRadioAccessTechnology = netinfo.serviceCurrentRadioAccessTechnology.allValues.firstObject;
67
- } else {
68
- // Fallback on earlier versions
69
- serviceCurrentRadioAccessTechnology = netinfo.currentRadioAccessTechnology;
70
- }
71
-
72
- if (netinfo) {
73
- if ([serviceCurrentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyGPRS] ||
74
- [serviceCurrentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyEdge] ||
75
- [serviceCurrentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMA1x]) {
76
- return EXCellularGeneration2G;
77
- } else if ([serviceCurrentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyWCDMA] ||
78
- [serviceCurrentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyHSDPA] ||
79
- [serviceCurrentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyHSUPA] ||
80
- [serviceCurrentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMAEVDORev0] ||
81
- [serviceCurrentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMAEVDORevA] ||
82
- [serviceCurrentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMAEVDORevB] ||
83
- [serviceCurrentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyeHRPD]) {
84
- return EXCellularGeneration3G;
85
- } else if ([serviceCurrentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyLTE]) {
86
- return EXCellularGeneration4G;
87
- } else if (@available(iOS 14.1, *) &&
88
- ([serviceCurrentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyNRNSA] ||
89
- [serviceCurrentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyNR])) {
90
- return EXCellularGeneration5G;
91
- }
92
- }
93
- return EXCellularGenerationUnknown;
94
- }
95
-
96
-
97
- - (CTCarrier *)carrier
98
- {
99
- CTTelephonyNetworkInfo *netinfo = [[CTTelephonyNetworkInfo alloc] init];
100
-
101
- if (@available(iOS 12.0, *)) {
102
- for (NSString *key in netinfo.serviceSubscriberCellularProviders) {
103
- CTCarrier *carrier = netinfo.serviceSubscriberCellularProviders[key];
104
- if (carrier.carrierName != nil) {
105
- return carrier;
106
- }
107
- }
108
-
109
- return [[netinfo.serviceSubscriberCellularProviders objectEnumerator] nextObject];
110
- }
111
-
112
- return netinfo.subscriberCellularProvider;
113
- }
114
-
115
- - (NSDictionary *)getCurrentCellularInfo
116
- {
117
- CTCarrier *carrier = [self carrier];
118
-
119
- return @{
120
- @"allowsVoip": @(carrier.allowsVOIP),
121
- @"carrier": EXNullIfNil(carrier.carrierName),
122
- @"isoCountryCode": EXNullIfNil(carrier.isoCountryCode),
123
- @"mobileCountryCode": EXNullIfNil(carrier.mobileCountryCode),
124
- @"mobileNetworkCode": EXNullIfNil(carrier.mobileNetworkCode),
125
- };
126
- }
127
-
128
- - (BOOL)allowsVoip
129
- {
130
- return [self carrier].allowsVOIP;
131
- }
132
-
133
- - (NSString *)getIsoCountryCode
134
- {
135
- return [self carrier].isoCountryCode;
136
- }
137
-
138
- - (NSString *)getCarrierName
139
- {
140
- return [self carrier].carrierName;
141
- }
142
-
143
- - (NSString *)getMobileCountryCode
144
- {
145
- return [self carrier].mobileCountryCode;
146
- }
147
-
148
- - (NSString *)getMobileNetworkCode
149
- {
150
- return [self carrier].mobileNetworkCode;
151
- }
152
-
153
- @end
package/unimodule.json DELETED
@@ -1,4 +0,0 @@
1
- {
2
- "name": "expo-cellular",
3
- "platforms": ["ios", "android", "web"]
4
- }