RxIAPv3
RxIAPv3 copied to clipboard
event handlers called by rx-methods
Hi,
When I use the method billingProcessor.purchaseObservable
the buying process is successful, but the observable does not emit anything. However the event handlers for no rx-methods are called.
Here I show the code snippet:
@Override
public void onPurchase(final ContinentSubscription continent) {
Timber.d("Id de la subscripción del continente: %s ", Utils.getSubscriptionIdFromContinentCode(continent.getCode()));
billingProcessor.purchaseObservable(this, Utils.getSubscriptionIdFromContinentCode(continent.getCode())).doOnNext(new Action1<PurchaseModel>() {
@Override
public void call(PurchaseModel purchaseModel) {
Timber.d("Purchase Model: %s", purchaseModel.toString());
Toast.makeText(ContinentsActivity.this, "Purchase Model: " + purchaseModel.toString(), Toast.LENGTH_LONG);
if (!purchaseModel.isSuccess())
throw new PurchaseFailException();
}
}).flatMap(new Func1<PurchaseModel, Observable<ConsumeModel>>() {
@Override
public Observable<ConsumeModel> call(PurchaseModel purchaseModel) {
Timber.d("Consume Model: %s ", purchaseModel.toString());
Toast.makeText(ContinentsActivity.this, "Consume Model: " + purchaseModel.toString(), Toast.LENGTH_LONG);
return billingProcessor.consumePurchaseObservable(purchaseModel.getPurchaseDataModel().getProductId());
}
}).doOnNext(new Action1<ConsumeModel>() {
@Override
public void call(ConsumeModel consumeModel) {
if (!consumeModel.isSuccess())
throw new ConsumeFailException();
}
})
the doOnNext responsible for checking the result of the process is never called. However the event handler onProductPurchased if it is called
@Override
public void onProductPurchased(String productId, PurchaseDataModel purchaseDataModel) {
Timber.d("onProductPurchased: %s, purchase datamodel: %s ", productId, purchaseDataModel.toString());
}
I have followed the example of the repository
thanks.
So, what you mean is that consumePurchaseObservable does not return a value downstream?
yes, billingProcessor.purchaseObservable does not return a value downstream.
Can you add a Subscriber and check if onError is called?
The above was an excerpt. The full flow is quite broad but in the end I subscribe in this way:
.subscribe(new Action1<Boolean>() {
@Override
public void call(Boolean result) {
hideLoadingDialog();
onSubscriptionSuccess();
reloadSubscriptions();
}
}, new CommonErrorHandler() {
@Override
public void onRetrofitException(JacksonApiError response) {
int code = response != null ? response.getCode() : -1;
hideLoadingDialog();
onSubscriptionError(code);
}
@Override
public void onOtherException(Throwable throwable) {
hideLoadingDialog();
onSubscriptionError(-1);
Timber.d(throwable.getMessage());
}
});
No error occurs, onProductPurchased event handler is called.
I've taken a look to handle handleActivityResult on BillingProcessor and in this method only billing listener is notified. then I should not concatenate operations to purchaseObservable?
Probably yes, but it is being a long time since I wrote, will have to re-investigate why I did that. Maybe it is because this operation has to invoke startActivityForResult()
internally and it can not use an Rx stream to notify back.
facing the same issue right now. any plans?