Skip to content

Commit

Permalink
Merge pull request #366 from qonversion/feature/sc-33816/promoOffers
Browse files Browse the repository at this point in the history
Promotional offers supported.
  • Loading branch information
SpertsyanKM authored Nov 25, 2024
2 parents c877173 + 5be0dc0 commit 9389f03
Show file tree
Hide file tree
Showing 55 changed files with 740 additions and 964 deletions.
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ android {

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "io.qonversion.sandwich:sandwich:5.1.7"
implementation "io.qonversion.sandwich:sandwich:5.2.0"
implementation 'com.google.code.gson:gson:2.9.0'
}
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ publish_to: 'none'
version: 1.0.0

environment:
sdk: ">=2.12.0 <3.0.0"
sdk: ">=2.14.0 <3.0.0"
flutter: ">=1.12.13+hotfix.6"

dependencies:
Expand Down
27 changes: 20 additions & 7 deletions ios/Classes/SwiftQonversionPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,12 @@ public class SwiftQonversionPlugin: NSObject, FlutterPlugin {
switch call.method {
case "initialize":
return initialize(args, result)

case "getPromotionalOffer":
return getPromotionalOffer(args, result)

case "purchase":
return purchase(args["productId"] as? String, quantity: args["quantity"] as? Int, contextKeys: args["contextKeys"] as? [String], result)
return purchase(args, result)

case "promoPurchase":
return promoPurchase(args["productId"] as? String, result)
Expand Down Expand Up @@ -204,19 +207,29 @@ public class SwiftQonversionPlugin: NSObject, FlutterPlugin {
qonversionSandwich?.identify(userId, getDefaultCompletion(result))
}

private func getPromotionalOffer(_ args: [String: Any], _ result: @escaping FlutterResult) {
guard let productId = args["productId"] as? String,
let discountId = args["discountId"] as? String else {
return result(FlutterError.noNecessaryData)
}

qonversionSandwich?.getPromotionalOffer(productId, productDiscountId:discountId, completion:getJsonCompletion(result))
}

private func products(_ result: @escaping FlutterResult) {
qonversionSandwich?.products(getDefaultCompletion(result))
}

private func purchase(_ productId: String?, quantity: Int?, contextKeys: [String]?, _ result: @escaping FlutterResult) {
guard let productId = productId else {
private func purchase(_ args: [String: Any], _ result: @escaping FlutterResult) {
guard let productId = args["productId"] as? String else {
return result(FlutterError.noNecessaryData)
}

let contextKeys = contextKeys ?? []
let quantity = quantity ?? 1

let contextKeys = args["contextKeys"] as? [String] ?? []
let quantity = args["quantity"] as? Int ?? 1
let promoOfferData = args["promoOffer"] as? [String: Any] ?? [:]

qonversionSandwich?.purchase(productId, quantity:quantity, contextKeys:contextKeys, completion: getJsonCompletion(result))
qonversionSandwich?.purchase(productId, quantity:quantity, contextKeys:contextKeys, promoOffer:promoOfferData, completion:getJsonCompletion(result))
}

private func promoPurchase(_ productId: String?, _ result: @escaping FlutterResult) {
Expand Down
2 changes: 1 addition & 1 deletion ios/qonversion_flutter.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |s|
s.source_files = 'Classes/**/*'
s.dependency 'Flutter'
s.platform = :ios, '9.0'
s.dependency "QonversionSandwich", "5.1.7"
s.dependency "QonversionSandwich", "5.2.0"

# Flutter.framework does not contain a i386 slice. Only x86_64 simulators are supported.
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'VALID_ARCHS[sdk=iphonesimulator*]' => 'x86_64' }
Expand Down
6 changes: 6 additions & 0 deletions lib/qonversion_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export 'src/dto/automations/event_type.dart';
export 'src/dto/attribution_provider.dart';
export 'src/dto/eligibility.dart';
export 'src/dto/entitlement.dart';
export 'src/dto/entitlement_grant_type.dart';
export 'src/dto/entitlement_renew_state.dart';
export 'src/dto/entitlement_source.dart';
export 'src/dto/entitlements_cache_lifetime.dart';
Expand All @@ -14,6 +15,7 @@ export 'src/dto/launch_mode.dart';
export 'src/dto/offerings.dart';
export 'src/dto/product.dart';
export 'src/dto/product_type.dart';
export 'src/dto/promotional_offer.dart';
export 'src/dto/purchase_model.dart';
export 'src/dto/purchase_options.dart';
export 'src/dto/purchase_options_builder.dart';
Expand All @@ -35,6 +37,10 @@ export 'src/dto/user_properties.dart';
export 'src/dto/user_property.dart';
export 'src/dto/user_property_key.dart';
export 'src/dto/sk_product/discount_payment_mode.dart';
export 'src/dto/sk_product/sk_payment_discount.dart';
export 'src/dto/sk_product/sk_product.dart';
export 'src/dto/sk_product/sk_product_discount.dart';
export 'src/dto/sk_product/subscription_period.dart';
export 'src/dto/sk_product/subscription_period_unit.dart';
export 'src/dto/sku_details/sku_details.dart';
export 'src/dto/store_product/product_inapp_details.dart';
Expand Down
57 changes: 9 additions & 48 deletions lib/src/dto/automations/action_result.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 7 additions & 34 deletions lib/src/dto/automations/event.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 3 additions & 42 deletions lib/src/dto/eligibility.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

76 changes: 24 additions & 52 deletions lib/src/dto/entitlement.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 5 additions & 7 deletions lib/src/dto/experiment.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9389f03

Please sign in to comment.