From b753586e07c1b152342a9b81f4434b63c1382031 Mon Sep 17 00:00:00 2001 From: Aliaksei Astafyeu Date: Thu, 23 Nov 2023 10:49:57 +0100 Subject: [PATCH] fix(fixed): skip enabling location settings if google services are unavailable --- .../EscPosPrinterDiscoveryModule.java | 16 ++++++++++++++++ example/ios/Podfile.lock | 4 ++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/android/src/main/java/com/reactnativeescposprinter/EscPosPrinterDiscoveryModule.java b/android/src/main/java/com/reactnativeescposprinter/EscPosPrinterDiscoveryModule.java index a8c017a..9ffb078 100644 --- a/android/src/main/java/com/reactnativeescposprinter/EscPosPrinterDiscoveryModule.java +++ b/android/src/main/java/com/reactnativeescposprinter/EscPosPrinterDiscoveryModule.java @@ -37,6 +37,10 @@ import com.google.android.gms.common.api.ResolvableApiException; import com.google.android.gms.common.api.CommonStatusCodes; +import com.google.android.gms.common.GoogleApiAvailability; +import com.google.android.gms.common.ConnectionResult; + + @ReactModule(name = EscPosPrinterDiscoveryModule.NAME) public class EscPosPrinterDiscoveryModule extends ReactContextBaseJavaModule implements ActivityEventListener { @@ -110,8 +114,20 @@ public void onNewIntent(Intent intent) { } + + public boolean isGoogleServiceAvailable() { + return GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(reactContext) == ConnectionResult.SUCCESS; + } + @ReactMethod public void enableLocationSetting(Promise promise) { + boolean isGoogleServiceAvailable = isGoogleServiceAvailable(); + + if (!isGoogleServiceAvailable) { + promise.resolve("SUCCESS"); + return; + } + Activity currentActivity = getCurrentActivity(); if (currentActivity == null) { promise.reject("Activity doesn't exist", ""); diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 7c74178..dae4ef7 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -377,7 +377,7 @@ PODS: - React-jsinspector (0.72.6) - React-logger (0.72.6): - glog - - react-native-esc-pos-printer (2.6.0): + - react-native-esc-pos-printer (3.0.1): - RCT-Folly (= 2021.07.22.00) - React-Core - react-native-safe-area-context (4.7.4): @@ -714,7 +714,7 @@ SPEC CHECKSUMS: React-jsiexecutor: 3bf18ff7cb03cd8dfdce08fbbc0d15058c1d71ae React-jsinspector: 194e32c6aab382d88713ad3dd0025c5f5c4ee072 React-logger: cebf22b6cf43434e471dc561e5911b40ac01d289 - react-native-esc-pos-printer: f5dd5e32b823fffceb414f2e1cf69b64a1dc9b3c + react-native-esc-pos-printer: 6e971d88f296caa084c7b52cee955db235bc5ed6 react-native-safe-area-context: 2cd91d532de12acdb0a9cbc8d43ac72a8e4c897c React-NativeModulesApple: 02e35e9a51e10c6422f04f5e4076a7c02243fff2 React-perflogger: e3596db7e753f51766bceadc061936ef1472edc3