Skip to content

Commit

Permalink
fix: added sdk check for android to avoid crash on lower versions
Browse files Browse the repository at this point in the history
  • Loading branch information
lazerblasters committed Oct 5, 2021
1 parent 40e5310 commit aa60a59
Showing 1 changed file with 25 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import android.graphics.Bitmap
import android.graphics.Point
import android.media.MediaMetadataRetriever
import android.net.Uri
import android.os.Build
import android.util.Base64
import android.util.Log
import android.util.SparseArray
Expand Down Expand Up @@ -355,29 +356,37 @@ class FeedbackReporterModule(val reactContext: ReactApplicationContext) : ReactC

@ReactMethod
fun setValue(key: String, value: String, promise: Promise) {
val storage = RNFRStorage(reactContext);
val result = storage.setValue(key, value);
val code = result.getInt("code");
val error = result.getString("error");

if (code == 200) {
promise.resolve(result);
if (Build.VERSION.SDK_INT >= 23) {
val storage = RNFRStorage(reactContext);
val result = storage.setValue(key, value);
val code = result.getInt("code");
val error = result.getString("error");

if (code == 200) {
promise.resolve(result);
} else {
promise.reject(null, error);
}
} else {
promise.reject(null, error);
promise.reject(null, "unsupported function below SDK 23");
}
}

@ReactMethod
fun getValue(key: String, promise: Promise) {
val storage = RNFRStorage(reactContext);
val result = storage.getValue(key);
val code = result.getInt("code");
val error = result.getString("error");

if (code == 200) {
promise.resolve(result);
if (Build.VERSION.SDK_INT >= 23) {
val storage = RNFRStorage(reactContext);
val result = storage.getValue(key);
val code = result.getInt("code");
val error = result.getString("error");

if (code == 200) {
promise.resolve(result);
} else {
promise.reject(null, error);
}
} else {
promise.reject(null, error);
promise.reject(null, "unsupported function below SDK 23");
}
}

Expand Down

0 comments on commit aa60a59

Please sign in to comment.