Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions android/src/main/java/com/eddieowens/RNBoundaryModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import android.support.v4.app.ActivityCompat;
import android.util.Log;

import com.eddieowens.errors.GeofenceErrorMessages;
import com.eddieowens.receivers.BoundaryEventBroadcastReceiver;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.LifecycleEventListener;
Expand All @@ -19,6 +20,7 @@
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.WritableArray;
import com.google.android.gms.location.Geofence;
import com.google.android.gms.location.GeofenceStatusCodes;
import com.google.android.gms.location.GeofencingClient;
import com.google.android.gms.location.GeofencingRequest;
import com.google.android.gms.location.LocationServices;
Expand Down Expand Up @@ -165,6 +167,9 @@ public void onSuccess(Void aVoid) {
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
if (e.getMessage().contains(Integer.toString(GeofenceStatusCodes.GEOFENCE_NOT_AVAILABLE))) {
promise.reject(new Exception(GeofenceErrorMessages.getErrorString(GeofenceStatusCodes.GEOFENCE_NOT_AVAILABLE)));
}
promise.reject(e);
}
});
Expand Down Expand Up @@ -200,6 +205,9 @@ public void onSuccess(Void aVoid) {
@Override
public void onFailure(@NonNull Exception e) {
Log.i(TAG, "Failed to add geofence.");
if (e.getMessage().contains(Integer.toString(GeofenceStatusCodes.GEOFENCE_NOT_AVAILABLE))) {
promise.reject(new Exception(GeofenceErrorMessages.getErrorString(GeofenceStatusCodes.GEOFENCE_NOT_AVAILABLE)));
}
promise.reject(e);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ private GeofenceErrorMessages() {}
public static String getErrorString(int errorCode) {
switch (errorCode) {
case GeofenceStatusCodes.GEOFENCE_NOT_AVAILABLE:
return "Geofence is not available";
return "Geofence is not available. Android emulator requires Settings -> Location -> Mode to be set at 'Battery Saving' or 'High Accuracy'";
case GeofenceStatusCodes.GEOFENCE_TOO_MANY_GEOFENCES:
return "Too many geofences";
case GeofenceStatusCodes.GEOFENCE_TOO_MANY_PENDING_INTENTS:
Expand Down
2 changes: 1 addition & 1 deletion typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface Boundary {
export interface BoundaryStatic {
on: (event: Events, callback: (boundaries: string[]) => void) => EmitterSubscription;
off: (event: Events) => void;
add: (boundary: Boundary) => Promise<string>;
add: (boundary: Boundary | Boundary[]) => Promise<string>;
remove: (id: string) => Promise<null>;
removeAll: () => Promise<null>;
}
Expand Down