Skip to content

Commit

Permalink
fix(fixed): skip enabling location settings if google services are un…
Browse files Browse the repository at this point in the history
…available
  • Loading branch information
tr3v3r committed Nov 23, 2023
1 parent dab1876 commit b753586
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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", "");
Expand Down
4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b753586

Please sign in to comment.