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

syncPurchases method with return value of CustomerInfo #1209

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
case "syncPurchases":
syncPurchases(result);
break;
case "syncPurchasesWith":
syncPurchasesWith(result);
break;
case "isAnonymous":
isAnonymous(result);
break;
Expand Down Expand Up @@ -520,6 +523,10 @@ private void syncPurchases(final Result result) {
result.success(null);
}

private void syncPurchasesWith(final Result result) {
CommonKt.syncPurchases(getOnResult(result));
}

private void isAnonymous(final Result result) {
result.success(CommonKt.isAnonymous());
}
Expand Down
2 changes: 2 additions & 0 deletions ios/Classes/PurchasesFlutterPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ - (void)handleMethodCall:(FlutterMethodCall *)call
[self getCustomerInfoWithResult:result];
} else if ([@"syncPurchases" isEqualToString:call.method]) {
[self syncPurchasesWithResult:result];
} else if ([@"syncPurchasesWith" isEqualToString:call.method]) {
[self syncPurchasesWithResult:result];
} else if ([@"enableAdServicesAttributionTokenCollection" isEqualToString:call.method]) {
[self enableAdServicesAttributionTokenCollection:result];
} else if ([@"recordPurchaseForProductID" isEqualToString:call.method]) {
Expand Down
13 changes: 13 additions & 0 deletions lib/purchases_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,19 @@ class Purchases {
/// successful purchase.
static Future<void> syncPurchases() => _channel.invokeMethod('syncPurchases');

/// This method will send all the purchases to the RevenueCat backend.
///
/// **WARNING**: Call this when using your own implementation of in-app
/// purchases.
///
/// This method should be called anytime a sync is needed, like after a
/// successful purchase.
static Future<CustomerInfo> syncPurchasesWithResult() async {
final result = await _channel.invokeMethod('syncPurchasesWith');
return CustomerInfo.fromJson(Map<String, dynamic>.from(result));
}


/// iOS only. Enable automatic collection of Apple Search Ad attribution. Disabled by
/// default
static Future<void> enableAdServicesAttributionTokenCollection() =>
Expand Down