Skip to content

Commit

Permalink
4.4.0 (#41)
Browse files Browse the repository at this point in the history
* Android userSubscriptionsHistory

* Android SDK version 4.4.2

* iOS userSubscriptionsHistory

* iOS SDK 4.4.2

* add versions.md file

---------

Co-authored-by: Kevin Herembourg <kevin.herembourg@gmail.com>
Co-authored-by: Chouaib Mounaime <chouaib@purchasely.com>
  • Loading branch information
chouaibMo and kherembourg authored Jun 19, 2024
1 parent 96a2ff1 commit d5c3ece
Show file tree
Hide file tree
Showing 21 changed files with 264 additions and 81 deletions.
23 changes: 23 additions & 0 deletions VERSIONS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
This file provides the underlying native SDK versions that the React Native SDK relies on.

| Version | iOS version | Android version |
|---------|-------------|-----------------|
| 4.0.0 | 4.0.0 | 4.0.0 |
| 4.0.1 | 4.0.1 | 4.0.0 |
| 4.0.2 | 4.0.3 | 4.0.0 |
| 4.1.0 | 4.1.3 | 4.1.1 |
| 4.1.1 | 4.1.4 | 4.1.1 |
| 4.1.2 | 4.1.4 | 4.1.1 |
| 4.1.3 | 4.1.4 | 4.1.2 |
| 4.1.4 | 4.1.5 | 4.1.2 |
| 4.2.0 | 4.2.0 | 4.2.0 |
| 4.2.1 | 4.2.1 | 4.2.1 |
| 4.2.2 | 4.2.2 | 4.2.2 |
| 4.2.3 | 4.2.3 | 4.2.3 |
| 4.2.4 | 4.2.4 | 4.2.3 |
| 4.3.0 | 4.3.0 | 4.3.0 |
| 4.3.1 | 4.3.3 | 4.3.1 |
| 4.3.2 | 4.3.3 | 4.3.3 |
| 4.3.3 | 4.3.4 | 4.3.4 |
| 4.3.4 | 4.3.6 | 4.3.5 |
| 4.4.0 | 4.4.2 | 4.4.2 |
1 change: 1 addition & 0 deletions publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ VERSION=$1
#replace version number in yaml file
sed -i '' "s/^.*version:.*$/version: ${VERSION}/" purchasely/pubspec.yaml
sed -i '' "s/^.*version:.*$/version: ${VERSION}/" purchasely_google/pubspec.yaml
sed -i '' "s/^.*purchasely_flutter:.*$/purchasely_flutter: ^${VERSION}/" purchasely_google/pubspec.yaml
sed -i '' "s/^.*version:.*$/version: ${VERSION}/" purchasely_android_player/pubspec.yaml

#replace version number in android plugin
Expand Down
8 changes: 8 additions & 0 deletions purchasely/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 4.4.0
- **Audience Targeting**: Added capability to segment audiences based on user's country and purchase history.
- **UI Enhancements**:
- Introduced a customizable header button as an alternative to the default close button.
- **Subscription Management**: New method `userSubscriptionsHistory` allows retrieval of expired subscriptions.
### Android
- **Google Play Billing**: Upgraded to version 6.
- **Paywall Engine**: Improved paywall engine for better performance.
## 4.3.4
### Fixes for Android
- Fixed presentations cache.
Expand Down
2 changes: 1 addition & 1 deletion purchasely/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@ dependencies {

api 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.0'

api 'io.purchasely:core:4.3.5'
api 'io.purchasely:core:4.4.2'
}
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ class PurchaselyFlutterPlugin: FlutterPlugin, MethodCallHandler, ActivityAware,
"displaySubscriptionCancellationInstruction" -> displaySubscriptionCancellationInstruction()
"isDeeplinkHandled" -> isDeeplinkHandled(call.argument<String>("deeplink"), result)
"userSubscriptions" -> launch { userSubscriptions(result) }
"userSubscriptionsHistory" -> launch { userSubscriptionsHistory(result) }
"presentSubscriptions" -> presentSubscriptions()
"setThemeMode" -> setThemeMode(call.argument<Int>("mode"))
"setAttribute" -> setAttribute(call.argument<Int>("attribute"), call.argument<String>("value"))
Expand Down Expand Up @@ -342,7 +343,7 @@ class PurchaselyFlutterPlugin: FlutterPlugin, MethodCallHandler, ActivityAware,
.userId(userId)
.build()

Purchasely.sdkBridgeVersion = "4.3.4"
Purchasely.sdkBridgeVersion = "4.4.0"
Purchasely.appTechnology = PLYAppTechnology.FLUTTER

Purchasely.start { isConfigured, error ->
Expand Down Expand Up @@ -624,6 +625,40 @@ class PurchaselyFlutterPlugin: FlutterPlugin, MethodCallHandler, ActivityAware,
}
}

private suspend fun userSubscriptionsHistory(result: Result) {
try {
val subscriptions = Purchasely.userSubscriptionsHistory()
val list = ArrayList<MutableMap<String, Any?>>()
for (data in subscriptions) {
val map = data.data.toMap().toMutableMap().apply {
this["subscriptionSource"] = when(data.data.storeType) {
StoreType.GOOGLE_PLAY_STORE -> StoreType.GOOGLE_PLAY_STORE.ordinal
StoreType.HUAWEI_APP_GALLERY -> StoreType.HUAWEI_APP_GALLERY.ordinal
StoreType.AMAZON_APP_STORE -> StoreType.AMAZON_APP_STORE.ordinal
StoreType.APPLE_APP_STORE -> StoreType.APPLE_APP_STORE.ordinal
else -> null
}

this["plan"] = transformPlanToMap(data.plan)

val plans = HashMap<String?, Any>()
data.product.plans.map {
plans.put(it.name, transformPlanToMap(it))
}
this["product"] = data.product.toMap().toMutableMap().apply {
this["plans"] = plans
}
remove("subscription_status") //TODO add in a future version after checking with iOS
}
list.add(map)
//list[data.data.id] = map
}
result.safeSuccess(list)
} catch (e: Exception) {
result.safeError("-1", e.message, e)
}
}

private fun presentSubscriptions() {
val intent = Intent(context, PLYSubscriptionsActivity::class.java)
activity?.startActivity(intent)
Expand Down
4 changes: 2 additions & 2 deletions purchasely/example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@ flutter {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

implementation 'io.purchasely:google-play:4.3.5'
implementation 'io.purchasely:player:4.3.5'
implementation 'io.purchasely:google-play:4.4.2'
implementation 'io.purchasely:player:4.4.2'
}
12 changes: 6 additions & 6 deletions purchasely/example/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
PODS:
- Flutter (1.0.0)
- Purchasely (4.3.3)
- Purchasely (4.4.2)
- purchasely_flutter (1.2.4):
- Flutter
- Purchasely (= 4.3.3)
- Purchasely (= 4.4.2)

DEPENDENCIES:
- Flutter (from `Flutter`)
Expand All @@ -20,10 +20,10 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/purchasely_flutter/ios"

SPEC CHECKSUMS:
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
Purchasely: 6e6d02b890d6b80281742ad117854158a25a03a4
purchasely_flutter: 62b89ae00e860cc0036be0b4633d0cb339df34fa
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
Purchasely: 79a6f04ffd4fd237963e0e08dfad54b7a41be4c1
purchasely_flutter: 459c2ef73150fae608cdd7cca02cc47a749fec01

PODFILE CHECKSUM: d20b79b0eed0a157c8056f71847018b651697d65

COCOAPODS: 1.14.3
COCOAPODS: 1.15.2
18 changes: 18 additions & 0 deletions purchasely/example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
B0B951C8E8BDFED00694AE22 /* [CP] Embed Pods Frameworks */,
BC2ADAF79A6B60AF446C275B /* [CP] Copy Pods Resources */,
);
buildRules = (
);
Expand Down Expand Up @@ -250,6 +251,23 @@
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
BC2ADAF79A6B60AF446C275B /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Copy Pods Resources";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
showEnvVarsInLog = 0;
};
DAA116370D546D43B34087C5 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down
16 changes: 15 additions & 1 deletion purchasely/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class _MyAppState extends State<MyApp> {
try {
List<PLYSubscription> subscriptions =
await Purchasely.userSubscriptions();
print(' ==> Subscriptions');
print(' ==> Active Subscriptions');
if (subscriptions.isNotEmpty) {
print(subscriptions.first.plan);
print(subscriptions.first.subscriptionSource);
Expand All @@ -87,6 +87,20 @@ class _MyAppState extends State<MyApp> {
print(e);
}

try {
List<PLYSubscription> expiredSubscriptions =
await Purchasely.userSubscriptionsHistory();
print(' ==> Expired Subscriptions');
if (expiredSubscriptions.isNotEmpty) {
print(expiredSubscriptions.first.plan);
print(expiredSubscriptions.first.subscriptionSource);
print(expiredSubscriptions.first.nextRenewalDate);
print(expiredSubscriptions.first.cancelledDate);
}
} catch (e) {
print(e);
}

List<PLYProduct> products = await Purchasely.allProducts();
inspect(products);

Expand Down
52 changes: 14 additions & 38 deletions purchasely/example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -75,30 +75,6 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
leak_tracker:
dependency: transitive
description:
name: leak_tracker
sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa"
url: "https://pub.dev"
source: hosted
version: "10.0.0"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0
url: "https://pub.dev"
source: hosted
version: "2.0.1"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47
url: "https://pub.dev"
source: hosted
version: "2.0.1"
lints:
dependency: transitive
description:
Expand All @@ -111,41 +87,41 @@ packages:
dependency: transitive
description:
name: matcher
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
url: "https://pub.dev"
source: hosted
version: "0.12.16+1"
version: "0.12.16"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
url: "https://pub.dev"
source: hosted
version: "0.8.0"
version: "0.5.0"
meta:
dependency: transitive
description:
name: meta
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
url: "https://pub.dev"
source: hosted
version: "1.11.0"
version: "1.10.0"
path:
dependency: transitive
description:
name: path
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
url: "https://pub.dev"
source: hosted
version: "1.9.0"
version: "1.8.3"
purchasely_flutter:
dependency: "direct main"
description:
path: ".."
relative: true
source: path
version: "4.3.0"
version: "4.4.0"
sky_engine:
dependency: transitive
description: flutter
Expand Down Expand Up @@ -207,14 +183,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.4"
vm_service:
web:
dependency: transitive
description:
name: vm_service
sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
name: web
sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152
url: "https://pub.dev"
source: hosted
version: "13.0.0"
version: "0.3.0"
sdks:
dart: ">=3.2.0-0 <4.0.0"
dart: ">=3.2.0-194.0.dev <4.0.0"
flutter: ">=1.20.0"
17 changes: 14 additions & 3 deletions purchasely/ios/Classes/SwiftPurchaselyFlutterPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ public class SwiftPurchaselyFlutterPlugin: NSObject, FlutterPlugin {
case "isDeeplinkHandled":
let parameter = arguments?["deeplink"] as? String
isDeeplinkHandled(parameter, result: result)
case "userSubscriptions":
userSubscriptions(result)
case "userSubscriptionsHistory":
userSubscriptionsHistory(result)
case "presentSubscriptions":
presentSubscriptions()
case "setThemeMode":
Expand Down Expand Up @@ -281,7 +281,7 @@ public class SwiftPurchaselyFlutterPlugin: NSObject, FlutterPlugin {
return
}

Purchasely.setSdkBridgeVersion("4.3.4")
Purchasely.setSdkBridgeVersion("4.4.0")
Purchasely.setAppTechnology(PLYAppTechnology.flutter)

let logLevel = PLYLogger.LogLevel(rawValue: (arguments["logLevel"] as? Int) ?? PLYLogger.LogLevel.debug.rawValue) ?? PLYLogger.LogLevel.debug
Expand Down Expand Up @@ -750,6 +750,17 @@ public class SwiftPurchaselyFlutterPlugin: NSObject, FlutterPlugin {
}
}

private func userSubscriptionsHistory(_ result: @escaping FlutterResult) {

DispatchQueue.main.async {
Purchasely.userSubscriptionsHistory { subscriptions in
result((subscriptions ?? []).compactMap { $0.toMap })
} failure: { error in
result(FlutterError.error(code:"-1", message:"failed to fetch user subscriptions history", error: error))
}
}
}

private func presentSubscriptions() {
if let controller = Purchasely.subscriptionsController() {
let navCtrl = UINavigationController.init(rootViewController: controller)
Expand Down
2 changes: 1 addition & 1 deletion purchasely/ios/purchasely_flutter.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Flutter Plugin for Purchasely SDK
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
s.swift_version = '5.0'

s.dependency 'Purchasely', '4.3.6'
s.dependency 'Purchasely', '4.4.2'
s.static_framework = true

end
Loading

0 comments on commit d5c3ece

Please sign in to comment.