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

Separate paywalls into a different package #919

Merged
merged 18 commits into from
Jan 4, 2024

Conversation

tonidero
Copy link
Contributor

@tonidero tonidero commented Jan 3, 2024

Creates purchases_flutter_ui flutter package in a folder with the functionality to presentPaywall/presentPaywallIfNeeded and removes it from the main sdk purchases_flutter.

This allows to keep the min sdk version of the main sdk lower, while still requiring a higher minSdk version for the new library.

@tonidero tonidero changed the title Separate paywalls module Create purchases_flutter_ui package Jan 3, 2024
# Remove purchases_flutter_ui so it's not included in the release of the main SDK
# Can't use .pubignore because it causes files to not be found when trying to
# deploy purchases_flutter_ui
sh('rm', '-rf', 'purchases_flutter_ui')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not ideal... But didn't want to modify the whole repo architecture right now. We can revisit later.

Dir.chdir('..') do
sh('flutter', 'pub', 'publish', '--dry-run')
end
github_release(version: current_version_number)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Separated this into its own job

Dangerfile
Gemfile
Gemfile.lock
pubspec.lock
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We were including a bunch of things on the published package that weren't needed... This file removes most of them.

Copy link
Contributor

Choose a reason for hiding this comment

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

amazing

@@ -0,0 +1 @@
../CHANGELOG.md
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm reusing the top-level changelog.

Copy link
Contributor Author

@tonidero tonidero left a comment

Choose a reason for hiding this comment

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

This is working locally for me now and passes the publish dry run. Next would be to actually publish the library.

environment:
# TODO: Check constraints are ok
sdk: '>=3.2.3 <4.0.0'
flutter: '>=3.3.0'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These were the defaults when creating a new plugin. I think it's ok to keep them, but lmk if you think otherwise

@@ -3,6 +3,7 @@ import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:purchases_flutter/purchases_flutter.dart';
import 'package:purchases_flutter_ui/purchases_flutter_ui.dart';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the new import, but the class is called RevenueCatUI. I thought it was ok, but lmk if you would prefer to rename the package as well.


import 'package:flutter/services.dart';

class RevenueCatUI {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I modified the generated code from the wizard to resemble more closely what we do in the existing plugin. The generated code changed things so everything wasn't all static methods and better supported different communication systems with the platform (other than methodchannel). But it felt more complex so I simplified it like this.


private lateinit var channel : MethodChannel

override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the existing plugin we also have the registerWith static method. That seems to be used for very old flutter versions, but we are not supporting those so I think it's ok to just have this.

# Examples
Our examples are located at [revenuecat_examples](https://github.com/RevenueCat/purchases-flutter/tree/main/revenuecat_examples).

### [Purchase Tester](https://github.com/RevenueCat/purchases-flutter/tree/main/revenuecat_examples/purchase_tester)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't add MagicWeather here since it's not using paywalls at the moment.

@tonidero tonidero marked this pull request as ready for review January 3, 2024 15:11
@tonidero tonidero requested a review from a team January 3, 2024 15:11
@tonidero
Copy link
Contributor Author

tonidero commented Jan 3, 2024

Note that I'm not reverting the minSdkVersion changes in the paywalls branch on the api-tester and purchase-tester apps, since those are still using the new library which does require the higher minSdk version.

Dangerfile
Gemfile
Gemfile.lock
pubspec.lock
Copy link
Contributor

Choose a reason for hiding this comment

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

amazing

fastlane/Fastfile Outdated Show resolved Hide resolved
purchases_flutter_ui/README.md Outdated Show resolved Hide resolved
purchases_flutter_ui/analysis_options.yaml Outdated Show resolved Hide resolved
}

private fun presentPaywall(result: Result, requiredEntitlementIdentifier: String?) {
val activity = getActivityFragment()
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this an activity or a fragment? Because the function is presentPaywallFromFragment(activity,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that function name could be confusing... This is an activity. Basically, we are presenting the paywall from the PaywallFragment, but we need the activity as a parameter to present the PaywallFragment.

@tonidero tonidero requested a review from vegaro January 3, 2024 16:44
@tonidero tonidero merged commit ede6a5d into paywalls Jan 4, 2024
8 checks passed
@tonidero tonidero deleted the separate-paywalls-module branch January 4, 2024 08:03
@tonidero tonidero changed the title Create purchases_flutter_ui package Separate paywalls into a different package Jan 4, 2024
tonidero added a commit that referenced this pull request Jan 4, 2024
This renames the `purchases_flutter_ui` package added in #919 to
`purchases_ui_flutter`
@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.

2 participants