Skip to content

Commit

Permalink
Fix error when promise is null
Browse files Browse the repository at this point in the history
  • Loading branch information
WouterFlorijn committed Apr 15, 2022
1 parent 680c93c commit 1a848c6
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ public RNUserIdentityModule(ReactApplicationContext reactContext) {
this.reactContext = reactContext;
this.reactContext.addActivityEventListener(new BaseActivityEventListener() {
public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {
if(requestCode == INTENT_REQUEST_CODE) {
if (resultCode == Activity.RESULT_OK) {
String accountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME);
promise.resolve(accountName);
} else {
promise.reject("USER_CANCELED_ACCOUNT_SELECTION", "User cancelled the account selection dialog");
if (requestCode == INTENT_REQUEST_CODE) {
if (promise != null) {
if (resultCode == Activity.RESULT_OK) {
String accountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME);
promise.resolve(accountName);
} else {
promise.reject("USER_CANCELED_ACCOUNT_SELECTION", "User cancelled the account selection dialog");
}
}
}
}
Expand Down Expand Up @@ -88,4 +90,4 @@ public void triggerAccountSelection(String message, String accountType, Promise
public String getName() {
return "RNUserIdentity";
}
}
}

0 comments on commit 1a848c6

Please sign in to comment.