Skip to content

Commit e5e6da8

Browse files
committed
Rejects the promise in if state is null
1 parent 38776b5 commit e5e6da8

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

android/src/main/java/com/geektime/rnonesignalandroid/RNOneSignal.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,11 @@ public void addEmailSubscriptionObserver() {
236236
@ReactMethod
237237
public void getDeviceState(Promise promise) {
238238
OSDeviceState state = OneSignal.getDeviceState();
239+
if (state == null) {
240+
Log.e("OneSignal", "getDeviceState: OSDeviceState is null");
241+
promise.reject("Null OSDeviceState", "OSDeviceState is null");
242+
return;
243+
}
239244
promise.resolve(RNUtils.jsonToWritableMap(state.toJSONObject()));
240245
}
241246

0 commit comments

Comments
 (0)