Enigmatic-Smile / fidel-android

FIDEL Android SDK
MIT License
5 stars 1 forks source link

Present() on Android has no callback #8

Closed amigax closed 3 years ago

amigax commented 3 years ago

How would I get a callback? Even though onActivityResult is a kind of callback, it wont let you return things apart from bools

ccorneliu commented 3 years ago

@amigax , if you're using the latest version of the SDK, you also have the choice of using the function below:

Fidel.setCardLinkingObserver(new FidelCardLinkingObserver() {
  @Override
  public void onCardLinkingFailed(LinkResultError linkResultError) {
      Log.e("Error", "Error message = " + linkResultError.message);
  }

  @Override
  public void onCardLinkingSucceeded(LinkResult linkResult) {
      Log.d("Success", "Linked card id = " + linkResult.id);
  }
});

We didn't include it as a parameter of the "present" function because we allow developers to choose how they'll get the card linking results.

Also onActivityResult actually provides more data, as shown in the example from our README:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if(requestCode == Fidel.FIDEL_LINK_CARD_REQUEST_CODE) {
        if(data != null && data.hasExtra(Fidel.FIDEL_LINK_CARD_RESULT_CARD)) {
            LinkResult card = (LinkResult)data.getParcelableExtra(Fidel.FIDEL_LINK_CARD_RESULT_CARD);

            Log.d("d", "CARD ID = " + card.id);
        }
    }
}