Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

presentPaywallIfNeeded always return Null #886

Closed
imSaharukh opened this issue Nov 28, 2023 · 6 comments · Fixed by RevenueCat/purchases-ios#3493
Closed

presentPaywallIfNeeded always return Null #886

imSaharukh opened this issue Nov 28, 2023 · 6 comments · Fixed by RevenueCat/purchases-ios#3493
Labels
bug Something isn't working pr:RevenueCatUI status: needs-additional-info Issues that are missing steps from bug template triaged

Comments

@imSaharukh
Copy link

  if (Platform.isIOS) {
    //get all Entitlement
    var purchaserInfo = await Purchases.getCustomerInfo();
    var entitlements = purchaserInfo.entitlements.all;

    log("entitlements $entitlements");

    var result = await Purchases.presentPaywallIfNeeded(
        entitlements.values.first.identifier);

    log("result $result");

    return;
  }

i'm always getting flutter: type 'Null' is not a subtype of type 'FutureOr' error

@imSaharukh imSaharukh added the bug Something isn't working label Nov 28, 2023
@RCGitBot
Copy link
Contributor

👀 We've just linked this issue to our internal tracker and notified the team. Thank you for reporting, we're checking this out!

@tonidero
Copy link
Contributor

Hi @imSaharukh, thanks for reporting this. Indeed this is a problem in the current beta of paywalls. We're working on a fix and will update this issue once it's shipped.

In the meantime, we suggest handling this error as a non-fatal exception. Not ideal, but we hope to have it fixed soon.

@BorisKest
Copy link

Same here. BTW are you going to make it possible to use a paywall from different offerings rather than the current one?

@NachoSoto
Copy link
Contributor

Thanks for reporting! A few questions:

  • Is this happening on Android, iOS, or both?
  • Are you seeing anything in the logs?

Looking at the code, if this is Android only, I believe what might be happening is that your MainActivity probably still inherits FlutterActivity, and you need to change it to inherit from PurchasesFlutterActivity to support paywalls.

I just updated the implementation so an error is forwarded instead: 704bd67

@NachoSoto NachoSoto added status: needs-additional-info Issues that are missing steps from bug template triaged pr:RevenueCatUI labels Dec 6, 2023
tonidero added a commit to RevenueCat/purchases-ios that referenced this issue Dec 18, 2023
)

### Description
This adds a new method to the `PaywallViewControllerDelegate` to
indicate when the `PaywallViewController` is dismissed.

This will be useful to listen to responses in the hybrids, since we need
to present the paywall and wait until it's been purchased/dismissed
before returning a value for the hybrids.

This will be needed to fix:
RevenueCat/purchases-flutter#886
@tonidero tonidero reopened this Dec 18, 2023
tonidero added a commit to RevenueCat/purchases-hybrid-common that referenced this issue Dec 20, 2023
This allows to set a `PaywallViewControllerDelegate` to the
`PaywallProxy` to allow to receive purchase events in the hybrids. This
is a first step to fix:
RevenueCat/purchases-flutter#886

### TODO
- [x] Expose a delegate method that gets called when the
PaywallViewController gets dismissed.
@tonidero
Copy link
Contributor

tonidero commented Jan 2, 2024

Hi everyone! We're aware of this issue. #916 should fix it temporarily by removing the return value from presentPaywall/presentPaywallIfNeeded. We plan to add a more future-proof API later so we can receive more data of what happened with the paywall.

@tonidero
Copy link
Contributor

tonidero commented Jan 2, 2024

Same here. BTW are you going to make it possible to use a paywall from different offerings rather than the current one?

Hi @BorisKest, sorry for missing this! Yeah, that's part of the roadmap but might not be in V1 of paywalls for flutter.

tonidero added a commit that referenced this issue Jan 2, 2024
Currently the `presentPaywall` and `presentPaywallIfNeeded` methods
return a boolean indicating whether a purchase happened in the paywall.
This API is confusing and not extensible and it wasn't properly working
in iOS, see: #886. This first PR removes the return value from the
method. In a future PR we will add proper result handling for the
paywalls. Until then, the clients won't know what happened when the
paywall was presented and will need to rely on the
`Purchases.getCustomerInfo()` method to respond appropriately.

This is a breaking change from the previous beta.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pr:RevenueCatUI status: needs-additional-info Issues that are missing steps from bug template triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants