Skip to content

Update to use PHC PaywallHelpers instead of custom activity#903

Merged
tonidero merged 7 commits into
paywallsfrom
use-phc-paywall-helper
Dec 22, 2023
Merged

Update to use PHC PaywallHelpers instead of custom activity#903
tonidero merged 7 commits into
paywallsfrom
use-phc-paywall-helper

Conversation

@tonidero

@tonidero tonidero commented Dec 21, 2023

Copy link
Copy Markdown
Contributor

After RevenueCat/purchases-hybrid-common#602, we can now use the PaywallHelpers.presentPaywallFromFragment method to present the paywall and receive a result back using an internal view model.

This makes it so the PurchasesFlutterActivity isn't needed anymore and we can make use of that functionality, shared with other hybrids.

Note that this does mean developers need to make sure their android activity inherits from FlutterFragmentActivity (or other FragmentActivity) and not FlutterActivity, as we need to present the fragment.

TODO

}

private @Nullable PurchasesFlutterActivity getActivityFragment() {
private @Nullable FlutterFragmentActivity getActivityFragment() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's update the docs and put this in the release notes for the next beta :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe our only docs for this beta currently live in the release notes right? Will update those when I make the release

if (activity instanceof FlutterFragmentActivity) {
return (FlutterFragmentActivity) activity;
} else {
Log.e(TAG, "Paywalls require your activity to subclass FlutterFragmentActivity");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to update this error now.

@tonidero tonidero force-pushed the use-phc-paywall-helper branch from d2ecb21 to ff01fbb Compare December 22, 2023 14:51
@tonidero tonidero force-pushed the use-phc-paywall-helper branch from ff01fbb to 69e804b Compare December 22, 2023 14:52
tonidero and others added 3 commits December 22, 2023 15:53
There was a new update from `freezed` that changed the generated files,
making our tests fail. This updates those files.
@tonidero tonidero marked this pull request as ready for review December 22, 2023 15:08
@tonidero tonidero requested a review from a team December 22, 2023 15:08

@vegaro vegaro left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tonidero tonidero merged commit a14db54 into paywalls Dec 22, 2023
@tonidero tonidero deleted the use-phc-paywall-helper branch December 22, 2023 15:55
@tonidero tonidero mentioned this pull request Dec 22, 2023
tonidero added a commit that referenced this pull request Dec 22, 2023
### New Features
* 📱 Initial support for cross-platform RevenueCat Paywalls 🐾 🧱 (#852)

#### Instructions:
- For Android, you need to change your `MainActivity` to subclass
`FlutterFragmentActivity` instead of `FlutterActivity`.
- Update `purchases-flutter` in your `pubspec.yaml`:
```yaml
dependencies:
  purchases_flutter: 6.6.0-beta.3
```

#### Usage:
```dart
await Purchases.presentPaywallIfNeeded("pro");
```

#### Limitations:

- Currently only full screen paywalls are supported
- There is no way to detect paywall events other than using
`addCustomerInfoUpdateListener`
- Android's `minSdkVersion` is temporarily increased from `19` to `24`
to support paywalls. This will be reverted in a future release as we
split `purchases_flutter` and `purchases_flutter_ui`

### Breaking changes from previous beta

- `PurchasesFlutterActivity` has been removed. Use
`FlutterFragmentActivity` provided by Flutter instead

### Fixes from previous beta
* Fix `presentPaywallIfNeeded` (#904) via Toni Rico (@tonidero)

### Other Changes
* Update paywalls latest main (#906) via Toni Rico (@tonidero)
* Update to use PHC PaywallHelpers instead of custom activity (#903) via
Toni Rico (@tonidero)
* Fix flutter analyze deprecation warnings (#872)
@tonidero tonidero mentioned this pull request Jan 5, 2024
tonidero added a commit that referenced this pull request Jan 5, 2024
### New features
* 📱 Initial support for cross-platform RevenueCat Paywalls 🐾 🧱 (#852)

#### Instructions:
- For Android, you need to change your `MainActivity` to subclass
`FlutterFragmentActivity` instead of `FlutterActivity`. Also, the min
sdk version of the new package is `24`. Please make sure your app's
`android/build.gradle` minSdkVersion has that or a higher version.
- Add `purchases-ui-flutter` in your `pubspec.yaml`:
```yaml
dependencies:
  purchases_ui_flutter: 6.15.0-beta.4
```

#### Usage:
```dart
import 'package:purchases_ui_flutter/purchases_ui_flutter.dart';

await RevenueCatUI.presentPaywallIfNeeded("pro");
```

#### Limitations:
- Currently only full screen paywalls are supported
- There is no way to detect paywall events other than using
`addCustomerInfoUpdateListener`

#### Breaking changes from previous beta:
- Paywalls functionality has been extracted into a new dependency called
purchases_ui_flutter. Add purchases_ui_flutter to your pubspec.yaml.
Before this release, it was part of the main RevenueCat SDK
`purchases_flutter`.
- A new import is required to use this functionality: `import
'package:purchases_ui_flutter/purchases_ui_flutter.dart';`
- Usage has changed the class from `Purchases.presentPaywall` to
`RevenueCatUI.presentPaywall`.
- `presentPaywall` and `presentPaywallIfNeeded` now don't return a
result. To detect purchases, please use `Purchases.getCustomerInfo` from
the `purchases_flutter` SDK. A return value will be added in future
releases.

### Other Changes
* Fix pub score for `purchases-ui-flutter` (#924) via Toni Rico
(@tonidero)
* Update `paywalls` to latest `main` (#923) via Toni Rico (@tonidero)
* Rename `purchases_flutter_ui` to `purchases_ui_flutter` (#921) via
Toni Rico (@tonidero)
* Separate paywalls into a different package (#919) via Toni Rico
(@tonidero)
* Remove result from presentPaywall methods (#916) via Toni Rico
(@tonidero)
* Update to use PHC PaywallHelpers instead of custom activity (#903) via
Toni Rico (@tonidero)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants