expo-cellular 4.3.0 β 5.0.1
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 +18 -0
- package/android/build.gradle +2 -2
- package/android/src/main/java/expo/modules/cellular/CellularGeneration.kt +3 -1
- package/android/src/main/java/expo/modules/cellular/CellularModule.kt +23 -0
- package/build/Cellular.d.ts +23 -1
- package/build/Cellular.d.ts.map +1 -1
- package/build/Cellular.js +46 -1
- package/build/Cellular.js.map +1 -1
- package/build/Cellular.types.d.ts +1 -0
- package/build/Cellular.types.d.ts.map +1 -1
- package/build/Cellular.types.js +1 -0
- package/build/Cellular.types.js.map +1 -1
- package/ios/ExpoCellular.podspec +1 -1
- package/package.json +3 -3
- package/plugin/build/withCellular.d.ts +1 -1
- package/plugin/build/withCellular.js +1 -1
- package/plugin/src/withCellular.ts +1 -1
- package/src/Cellular.ts +57 -2
- package/src/Cellular.types.ts +7 -0
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,24 @@
|
|
|
10
10
|
|
|
11
11
|
### π‘ Others
|
|
12
12
|
|
|
13
|
+
## 5.0.1 β 2022-10-28
|
|
14
|
+
|
|
15
|
+
_This version does not introduce any user-facing changes._
|
|
16
|
+
|
|
17
|
+
## 5.0.0 β 2022-10-25
|
|
18
|
+
|
|
19
|
+
### π Breaking changes
|
|
20
|
+
|
|
21
|
+
- Bumped iOS deployment target to 13.0 and deprecated support for iOS 12. ([#18873](https://github.com/expo/expo/pull/18873) by [@tsapeta](https://github.com/tsapeta))
|
|
22
|
+
|
|
23
|
+
### π Bug fixes
|
|
24
|
+
|
|
25
|
+
- Added missing permissions requester. ([#19633](https://github.com/expo/expo/pull/19633) by [@lukmccall](https://github.com/lukmccall))
|
|
26
|
+
|
|
27
|
+
### π‘ Others
|
|
28
|
+
|
|
29
|
+
- [plugin] Migrate import from @expo/config-plugins to expo/config-plugins and @expo/config-types to expo/config. ([#18855](https://github.com/expo/expo/pull/18855) by [@brentvatne](https://github.com/brentvatne))
|
|
30
|
+
|
|
13
31
|
## 4.3.0 β 2022-07-07
|
|
14
32
|
|
|
15
33
|
### π‘ Others
|
package/android/build.gradle
CHANGED
|
@@ -3,7 +3,7 @@ apply plugin: 'kotlin-android'
|
|
|
3
3
|
apply plugin: 'maven-publish'
|
|
4
4
|
|
|
5
5
|
group = 'host.exp.exponent'
|
|
6
|
-
version = '
|
|
6
|
+
version = '5.0.1'
|
|
7
7
|
|
|
8
8
|
buildscript {
|
|
9
9
|
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
@@ -74,7 +74,7 @@ android {
|
|
|
74
74
|
minSdkVersion safeExtGet("minSdkVersion", 21)
|
|
75
75
|
targetSdkVersion safeExtGet("targetSdkVersion", 31)
|
|
76
76
|
versionCode 11
|
|
77
|
-
versionName '
|
|
77
|
+
versionName '5.0.1'
|
|
78
78
|
}
|
|
79
79
|
lintOptions {
|
|
80
80
|
abortOnError false
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
package expo.modules.cellular
|
|
2
2
|
|
|
3
|
+
import android.Manifest
|
|
3
4
|
import android.annotation.SuppressLint
|
|
4
5
|
import android.content.Context
|
|
5
6
|
import android.net.sip.SipManager
|
|
6
7
|
import android.os.Build
|
|
7
8
|
import android.telephony.TelephonyManager
|
|
8
9
|
import android.util.Log
|
|
10
|
+
import expo.modules.interfaces.permissions.Permissions
|
|
11
|
+
import expo.modules.kotlin.Promise
|
|
12
|
+
import expo.modules.kotlin.exception.Exceptions
|
|
9
13
|
import expo.modules.kotlin.modules.Module
|
|
10
14
|
import expo.modules.kotlin.modules.ModuleDefinition
|
|
11
15
|
|
|
@@ -53,6 +57,22 @@ class CellularModule : Module() {
|
|
|
53
57
|
AsyncFunction("getMobileNetworkCodeAsync") {
|
|
54
58
|
telephonyManager()?.simOperator?.substring(3)
|
|
55
59
|
}
|
|
60
|
+
|
|
61
|
+
AsyncFunction("requestPermissionsAsync") { promise: Promise ->
|
|
62
|
+
Permissions.askForPermissionsWithPermissionsManager(
|
|
63
|
+
permissionsManager,
|
|
64
|
+
promise,
|
|
65
|
+
Manifest.permission.READ_PHONE_STATE
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
AsyncFunction("getPermissionsAsync") { promise: Promise ->
|
|
70
|
+
Permissions.getPermissionsWithPermissionsManager(
|
|
71
|
+
permissionsManager,
|
|
72
|
+
promise,
|
|
73
|
+
Manifest.permission.READ_PHONE_STATE
|
|
74
|
+
)
|
|
75
|
+
}
|
|
56
76
|
}
|
|
57
77
|
|
|
58
78
|
private fun telephonyManager() =
|
|
@@ -63,6 +83,9 @@ class CellularModule : Module() {
|
|
|
63
83
|
private val context
|
|
64
84
|
get() = requireNotNull(appContext.reactContext)
|
|
65
85
|
|
|
86
|
+
private val permissionsManager: Permissions
|
|
87
|
+
get() = appContext.permissions ?: throw Exceptions.PermissionsModuleNotFound()
|
|
88
|
+
|
|
66
89
|
@SuppressLint("MissingPermission")
|
|
67
90
|
private fun getCurrentGeneration(): Int {
|
|
68
91
|
val telephonyManager = telephonyManager()
|
package/build/Cellular.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CellularGeneration } from './Cellular.types';
|
|
1
|
+
import { CellularGeneration, PermissionResponse } from './Cellular.types';
|
|
2
2
|
export { CellularGeneration };
|
|
3
3
|
/**
|
|
4
4
|
* Indicates if the carrier allows making VoIP calls on its network. On Android, this checks whether
|
|
@@ -95,6 +95,10 @@ export declare const mobileNetworkCode: string | null;
|
|
|
95
95
|
/**
|
|
96
96
|
* @return Returns a promise which fulfils with a [`Cellular.CellularGeneration`](#cellulargeneration)
|
|
97
97
|
* enum value that represents the current cellular-generation type.
|
|
98
|
+
*
|
|
99
|
+
* You will need to check if the native permission has been accepted to obtain generation.
|
|
100
|
+
* If the permission is denied `getCellularGenerationAsync` will resolve to `Cellular.Cellular Generation.UNKNOWN`.
|
|
101
|
+
|
|
98
102
|
*
|
|
99
103
|
* On web, this method uses [`navigator.connection.effectiveType`](https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation/effectiveType)
|
|
100
104
|
* to detect the effective type of the connection using a combination of recently observed
|
|
@@ -196,4 +200,22 @@ export declare function getMobileCountryCodeAsync(): Promise<string | null>;
|
|
|
196
200
|
* ```
|
|
197
201
|
*/
|
|
198
202
|
export declare function getMobileNetworkCodeAsync(): Promise<string | null>;
|
|
203
|
+
/**
|
|
204
|
+
* Checks user's permissions for accessing phone state.
|
|
205
|
+
*/
|
|
206
|
+
export declare function getPermissionsAsync(): Promise<PermissionResponse>;
|
|
207
|
+
/**
|
|
208
|
+
* Asks the user to grant permissions for accessing the phone state.
|
|
209
|
+
*/
|
|
210
|
+
export declare function requestPermissionsAsync(): Promise<PermissionResponse>;
|
|
211
|
+
/**
|
|
212
|
+
* Check or request permissions to access the phone state.
|
|
213
|
+
* This uses both `Cellular.requestPermissionsAsync` and `Cellular.getPermissionsAsync` to interact with the permissions.
|
|
214
|
+
*
|
|
215
|
+
* @example
|
|
216
|
+
* ```ts
|
|
217
|
+
* const [status, requestPermission] = Cellular.usePermissions();
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
220
|
+
export declare const usePermissions: (options?: import("expo-modules-core").PermissionHookOptions<object> | undefined) => [PermissionResponse | null, () => Promise<PermissionResponse>, () => Promise<PermissionResponse>];
|
|
199
221
|
//# sourceMappingURL=Cellular.d.ts.map
|
package/build/Cellular.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Cellular.d.ts","sourceRoot":"","sources":["../src/Cellular.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Cellular.d.ts","sourceRoot":"","sources":["../src/Cellular.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAG1E,OAAO,EAAE,kBAAkB,EAAE,CAA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"}
|
package/build/Cellular.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UnavailabilityError } from 'expo-modules-core';
|
|
1
|
+
import { createPermissionHook, PermissionStatus, Platform, UnavailabilityError, } from 'expo-modules-core';
|
|
2
2
|
import { CellularGeneration } from './Cellular.types';
|
|
3
3
|
import ExpoCellular from './ExpoCellular';
|
|
4
4
|
export { CellularGeneration };
|
|
@@ -107,6 +107,10 @@ export const mobileNetworkCode = ExpoCellular
|
|
|
107
107
|
/**
|
|
108
108
|
* @return Returns a promise which fulfils with a [`Cellular.CellularGeneration`](#cellulargeneration)
|
|
109
109
|
* enum value that represents the current cellular-generation type.
|
|
110
|
+
*
|
|
111
|
+
* You will need to check if the native permission has been accepted to obtain generation.
|
|
112
|
+
* If the permission is denied `getCellularGenerationAsync` will resolve to `Cellular.Cellular Generation.UNKNOWN`.
|
|
113
|
+
|
|
110
114
|
*
|
|
111
115
|
* On web, this method uses [`navigator.connection.effectiveType`](https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation/effectiveType)
|
|
112
116
|
* to detect the effective type of the connection using a combination of recently observed
|
|
@@ -238,4 +242,45 @@ export async function getMobileNetworkCodeAsync() {
|
|
|
238
242
|
}
|
|
239
243
|
return await ExpoCellular.getMobileNetworkCodeAsync();
|
|
240
244
|
}
|
|
245
|
+
/**
|
|
246
|
+
* Checks user's permissions for accessing phone state.
|
|
247
|
+
*/
|
|
248
|
+
export async function getPermissionsAsync() {
|
|
249
|
+
if (Platform.OS === 'android') {
|
|
250
|
+
return await ExpoCellular.getPermissionsAsync();
|
|
251
|
+
}
|
|
252
|
+
return {
|
|
253
|
+
status: PermissionStatus.GRANTED,
|
|
254
|
+
expires: 'never',
|
|
255
|
+
granted: true,
|
|
256
|
+
canAskAgain: true,
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Asks the user to grant permissions for accessing the phone state.
|
|
261
|
+
*/
|
|
262
|
+
export async function requestPermissionsAsync() {
|
|
263
|
+
if (Platform.OS === 'android') {
|
|
264
|
+
return await ExpoCellular.requestPermissionsAsync();
|
|
265
|
+
}
|
|
266
|
+
return {
|
|
267
|
+
status: PermissionStatus.GRANTED,
|
|
268
|
+
expires: 'never',
|
|
269
|
+
granted: true,
|
|
270
|
+
canAskAgain: true,
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Check or request permissions to access the phone state.
|
|
275
|
+
* This uses both `Cellular.requestPermissionsAsync` and `Cellular.getPermissionsAsync` to interact with the permissions.
|
|
276
|
+
*
|
|
277
|
+
* @example
|
|
278
|
+
* ```ts
|
|
279
|
+
* const [status, requestPermission] = Cellular.usePermissions();
|
|
280
|
+
* ```
|
|
281
|
+
*/
|
|
282
|
+
export const usePermissions = createPermissionHook({
|
|
283
|
+
getMethod: getPermissionsAsync,
|
|
284
|
+
requestMethod: requestPermissionsAsync,
|
|
285
|
+
});
|
|
241
286
|
//# sourceMappingURL=Cellular.js.map
|
package/build/Cellular.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Cellular.js","sourceRoot":"","sources":["../src/Cellular.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAE9B,cAAc;AACd;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,UAAU,GAAmB,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC;AAExF,cAAc;AACd;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,OAAO,GAAkB,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;A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AAM,CAAC,KAAK,UAAU,mBAAmB;IACvC,IAAI,CAAC,YAAY,CAAC,mBAAmB,EAAE;QACrC,MAAM,IAAI,mBAAmB,CAAC,eAAe,EAAE,qBAAqB,CAAC,CAAC;KACvE;IACD,OAAO,MAAM,YAAY,CAAC,mBAAmB,EAAE,CAAC;AAClD,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB;IAC7C,IAAI,CAAC,YAAY,CAAC,yBAAyB,EAAE;QAC3C,MAAM,IAAI,mBAAmB,CAAC,eAAe,EAAE,2BAA2B,CAAC,CAAC;KAC7E;IACD,OAAO,MAAM,YAAY,CAAC,yBAAyB,EAAE,CAAC;AACxD,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB;IAC7C,IAAI,CAAC,YAAY,CAAC,yBAAyB,EAAE;QAC3C,MAAM,IAAI,mBAAmB,CAAC,eAAe,EAAE,2BAA2B,CAAC,CAAC;KAC7E;IACD,OAAO,MAAM,YAAY,CAAC,yBAAyB,EAAE,CAAC;AACxD,CAAC","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"]}
|
|
1
|
+
{"version":3,"file":"Cellular.js","sourceRoot":"","sources":["../src/Cellular.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,QAAQ,EACR,mBAAmB,GACpB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,kBAAkB,EAAsB,MAAM,kBAAkB,CAAC;AAC1E,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAE9B,cAAc;AACd;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,UAAU,GAAmB,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,C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,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS,EAAE;QAC7B,OAAO,MAAM,YAAY,CAAC,uBAAuB,EAAE,CAAC;KACrD;IAED,OAAO;QACL,MAAM,EAAE,gBAAgB,CAAC,OAAO;QAChC,OAAO,EAAE,OAAO;QAChB,OAAO,EAAE,IAAI;QACb,WAAW,EAAE,IAAI;KAClB,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,oBAAoB,CAAC;IACjD,SAAS,EAAE,mBAAmB;IAC9B,aAAa,EAAE,uBAAuB;CACvC,CAAC,CAAC","sourcesContent":["import {\n createPermissionHook,\n PermissionStatus,\n Platform,\n UnavailabilityError,\n} from 'expo-modules-core';\n\nimport { CellularGeneration, PermissionResponse } 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 * You will need to check if the native permission has been accepted to obtain generation. \n * If the permission is denied `getCellularGenerationAsync` will resolve to `Cellular.Cellular Generation.UNKNOWN`.\n\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\n/**\n * Checks user's permissions for accessing phone state.\n */\nexport async function getPermissionsAsync(): Promise<PermissionResponse> {\n if (Platform.OS === 'android') {\n return await ExpoCellular.getPermissionsAsync();\n }\n\n return {\n status: PermissionStatus.GRANTED,\n expires: 'never',\n granted: true,\n canAskAgain: true,\n };\n}\n\n/**\n * Asks the user to grant permissions for accessing the phone state.\n */\nexport async function requestPermissionsAsync(): Promise<PermissionResponse> {\n if (Platform.OS === 'android') {\n return await ExpoCellular.requestPermissionsAsync();\n }\n\n return {\n status: PermissionStatus.GRANTED,\n expires: 'never',\n granted: true,\n canAskAgain: true,\n };\n}\n\n/**\n * Check or request permissions to access the phone state.\n * This uses both `Cellular.requestPermissionsAsync` and `Cellular.getPermissionsAsync` to interact with the permissions.\n *\n * @example\n * ```ts\n * const [status, requestPermission] = Cellular.usePermissions();\n * ```\n */\nexport const usePermissions = createPermissionHook({\n getMethod: getPermissionsAsync,\n requestMethod: requestPermissionsAsync,\n});\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Cellular.types.d.ts","sourceRoot":"","sources":["../src/Cellular.types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Cellular.types.d.ts","sourceRoot":"","sources":["../src/Cellular.types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,mBAAmB,CAAC;AAG3B;;;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"}
|
package/build/Cellular.types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Cellular.types.js","sourceRoot":"","sources":["../src/Cellular.types.ts"],"names":[],"mappings":"AAAA,cAAc;AACd;;;GAGG;AACH,MAAM,CAAN,IAAY,kBAqBX;AArBD,WAAY,kBAAkB;IAC5B;;OAEG;IACH,iEAAW,CAAA;IACX;;OAEG;IACH,yEAAe,CAAA;IACf;;OAEG;IACH,yEAAe,CAAA;IACf;;OAEG;IACH,yEAAe,CAAA;IACf;;OAEG;IACH,yEAAe,CAAA;AACjB,CAAC,EArBW,kBAAkB,KAAlB,kBAAkB,QAqB7B","sourcesContent":["// @needsAudit\n/**\n * Describes the current generation of the cellular connection. It is an enum with these possible\n * values:\n */\nexport enum CellularGeneration {\n /**\n * Either we are not currently connected to a cellular network or type could not be determined.\n */\n UNKNOWN = 0,\n /**\n * Currently connected to a 2G cellular network. Includes CDMA, EDGE, GPRS, and IDEN type connections.\n */\n CELLULAR_2G = 1,\n /**\n * Currently connected to a 3G cellular network. Includes EHRPD, EVDO, HSPA, HSUPA, HSDPA, and UTMS type connections.\n */\n CELLULAR_3G = 2,\n /**\n * Currently connected to a 4G cellular network. Includes HSPAP and LTE type connections.\n */\n CELLULAR_4G = 3,\n /**\n * Currently connected to a 5G cellular network. Includes NR and NRNSA type connections.\n */\n CELLULAR_5G = 4,\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Cellular.types.js","sourceRoot":"","sources":["../src/Cellular.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,gBAAgB,GAGjB,MAAM,mBAAmB,CAAC;AAE3B,cAAc;AACd;;;GAGG;AACH,MAAM,CAAN,IAAY,kBAqBX;AArBD,WAAY,kBAAkB;IAC5B;;OAEG;IACH,iEAAW,CAAA;IACX;;OAEG;IACH,yEAAe,CAAA;IACf;;OAEG;IACH,yEAAe,CAAA;IACf;;OAEG;IACH,yEAAe,CAAA;IACf;;OAEG;IACH,yEAAe,CAAA;AACjB,CAAC,EArBW,kBAAkB,KAAlB,kBAAkB,QAqB7B","sourcesContent":["export {\n PermissionResponse,\n PermissionStatus,\n PermissionExpiration,\n PermissionHookOptions,\n} from 'expo-modules-core';\n\n// @needsAudit\n/**\n * Describes the current generation of the cellular connection. It is an enum with these possible\n * values:\n */\nexport enum CellularGeneration {\n /**\n * Either we are not currently connected to a cellular network or type could not be determined.\n */\n UNKNOWN = 0,\n /**\n * Currently connected to a 2G cellular network. Includes CDMA, EDGE, GPRS, and IDEN type connections.\n */\n CELLULAR_2G = 1,\n /**\n * Currently connected to a 3G cellular network. Includes EHRPD, EVDO, HSPA, HSUPA, HSDPA, and UTMS type connections.\n */\n CELLULAR_3G = 2,\n /**\n * Currently connected to a 4G cellular network. Includes HSPAP and LTE type connections.\n */\n CELLULAR_4G = 3,\n /**\n * Currently connected to a 5G cellular network. Includes NR and NRNSA type connections.\n */\n CELLULAR_5G = 4,\n}\n"]}
|
package/ios/ExpoCellular.podspec
CHANGED
|
@@ -10,7 +10,7 @@ Pod::Spec.new do |s|
|
|
|
10
10
|
s.license = package['license']
|
|
11
11
|
s.author = package['author']
|
|
12
12
|
s.homepage = package['homepage']
|
|
13
|
-
s.platform = :ios, '
|
|
13
|
+
s.platform = :ios, '13.0'
|
|
14
14
|
s.swift_version = '5.4'
|
|
15
15
|
s.source = { git: 'https://github.com/expo/expo.git' }
|
|
16
16
|
s.static_framework = true
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-cellular",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.1",
|
|
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",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"homepage": "https://docs.expo.dev/versions/latest/sdk/cellular/",
|
|
32
32
|
"dependencies": {},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"expo-module-scripts": "^
|
|
34
|
+
"expo-module-scripts": "^3.0.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"expo": "*"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "59081bb17e727b10f2a00cd07bb45cd283a6f6a5"
|
|
40
40
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const config_plugins_1 = require("
|
|
3
|
+
const config_plugins_1 = require("expo/config-plugins");
|
|
4
4
|
const pkg = require('expo-cellular/package.json');
|
|
5
5
|
const withCellular = (config) => {
|
|
6
6
|
config = config_plugins_1.AndroidConfig.Permissions.withPermissions(config, [
|
package/src/Cellular.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
createPermissionHook,
|
|
3
|
+
PermissionStatus,
|
|
4
|
+
Platform,
|
|
5
|
+
UnavailabilityError,
|
|
6
|
+
} from 'expo-modules-core';
|
|
2
7
|
|
|
3
|
-
import { CellularGeneration } from './Cellular.types';
|
|
8
|
+
import { CellularGeneration, PermissionResponse } from './Cellular.types';
|
|
4
9
|
import ExpoCellular from './ExpoCellular';
|
|
5
10
|
|
|
6
11
|
export { CellularGeneration };
|
|
@@ -115,6 +120,10 @@ export const mobileNetworkCode: string | null = ExpoCellular
|
|
|
115
120
|
/**
|
|
116
121
|
* @return Returns a promise which fulfils with a [`Cellular.CellularGeneration`](#cellulargeneration)
|
|
117
122
|
* enum value that represents the current cellular-generation type.
|
|
123
|
+
*
|
|
124
|
+
* You will need to check if the native permission has been accepted to obtain generation.
|
|
125
|
+
* If the permission is denied `getCellularGenerationAsync` will resolve to `Cellular.Cellular Generation.UNKNOWN`.
|
|
126
|
+
|
|
118
127
|
*
|
|
119
128
|
* On web, this method uses [`navigator.connection.effectiveType`](https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation/effectiveType)
|
|
120
129
|
* to detect the effective type of the connection using a combination of recently observed
|
|
@@ -251,3 +260,49 @@ export async function getMobileNetworkCodeAsync(): Promise<string | null> {
|
|
|
251
260
|
}
|
|
252
261
|
return await ExpoCellular.getMobileNetworkCodeAsync();
|
|
253
262
|
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Checks user's permissions for accessing phone state.
|
|
266
|
+
*/
|
|
267
|
+
export async function getPermissionsAsync(): Promise<PermissionResponse> {
|
|
268
|
+
if (Platform.OS === 'android') {
|
|
269
|
+
return await ExpoCellular.getPermissionsAsync();
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
return {
|
|
273
|
+
status: PermissionStatus.GRANTED,
|
|
274
|
+
expires: 'never',
|
|
275
|
+
granted: true,
|
|
276
|
+
canAskAgain: true,
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Asks the user to grant permissions for accessing the phone state.
|
|
282
|
+
*/
|
|
283
|
+
export async function requestPermissionsAsync(): Promise<PermissionResponse> {
|
|
284
|
+
if (Platform.OS === 'android') {
|
|
285
|
+
return await ExpoCellular.requestPermissionsAsync();
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
return {
|
|
289
|
+
status: PermissionStatus.GRANTED,
|
|
290
|
+
expires: 'never',
|
|
291
|
+
granted: true,
|
|
292
|
+
canAskAgain: true,
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Check or request permissions to access the phone state.
|
|
298
|
+
* This uses both `Cellular.requestPermissionsAsync` and `Cellular.getPermissionsAsync` to interact with the permissions.
|
|
299
|
+
*
|
|
300
|
+
* @example
|
|
301
|
+
* ```ts
|
|
302
|
+
* const [status, requestPermission] = Cellular.usePermissions();
|
|
303
|
+
* ```
|
|
304
|
+
*/
|
|
305
|
+
export const usePermissions = createPermissionHook({
|
|
306
|
+
getMethod: getPermissionsAsync,
|
|
307
|
+
requestMethod: requestPermissionsAsync,
|
|
308
|
+
});
|
package/src/Cellular.types.ts
CHANGED