Skip to content

Commit

Permalink
Merge pull request #12 from superwall/hotfix/fix-hot-restart
Browse files Browse the repository at this point in the history
Hotfix/fix hot restart
  • Loading branch information
yusuftor authored Jun 19, 2024
2 parents 134d6fa + 793a67e commit 2028246
Show file tree
Hide file tree
Showing 21 changed files with 269 additions and 279 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,29 @@

The changelog for `Superwall`. Also see the [releases](https://github.com/superwall/Superwall-Flutter/releases) on GitHub.

## 1.1.9

### Enhancements

- Upgrades Android SDK to 1.1.8. [View Android SDK release notes](https://github.com/superwall-me/Superwall-Android/releases/tag/1.1.8)

### Fixes

- Bumps minimum Kotlin version to 1.8.0 and Android Gradle Plugin to 8.1.0 to be able to be
compatible with the latest Android SDK. This was necessary for important bug fixes.
- SW-2868: Fixes transaction issues caused by hot restart.

## 1.1.8

### Enhancements

- Upgrades iOS SDK to 3.6.6. [View iOS SDK release notes](https://github.com/superwall-me/Superwall-iOS/releases/tag/3.6.6)
- Upgrades Android SDK to 1.1.7. [View Android SDK release notes](https://github.com/superwall-me/Superwall-Android/releases/tag/1.1.7)

## 1.1.7

### Enhancements

- Upgrades iOS SDK to 3.6.5. [View iOS SDK release notes](https://github.com/superwall-me/Superwall-iOS/releases/tag/3.6.5)

## 1.1.6
Expand Down
16 changes: 2 additions & 14 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
group 'com.superwall.superwallkit_flutter'
version '1.0-SNAPSHOT'

buildscript {
ext.kotlin_version = '1.7.10'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

allprojects {
repositories {
Expand Down Expand Up @@ -81,11 +69,11 @@ android {
buildConfigField "boolean", "WAIT_FOR_DEBUGGER", waitForDebugger
}
}

android.buildFeatures.buildConfig true
dependencies {
testImplementation 'org.jetbrains.kotlin:kotlin-test'
testImplementation 'org.mockito:mockito-core:5.0.0'

implementation "com.superwall.sdk:superwall-android:1.1.7"
implementation "com.superwall.sdk:superwall-android:1.1.8"
implementation 'com.android.billingclient:billing:6.1.0'
}
4 changes: 4 additions & 0 deletions android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
plugins {
id "com.android.application" version "8.1.0" apply false
id "org.jetbrains.kotlin.android" version "1.8.0" apply false
}
rootProject.name = 'superwallkit_flutter'
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ class SuperwallBridge(
val isLoggedIn = Superwall.instance.isLoggedIn
result.success(isLoggedIn)
}
"getIsInitialized" -> {
val isInitialized = Superwall.initialized
result.success(isInitialized)
}
"getPresentedViewController" -> {
// TODO: Since UIViewController cannot be returned directly to Dart, handle appropriately
result.notImplemented()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ fun SuperwallEvent.toJson(): Map<String, Any?> {
is SuperwallEvent.IdentityAlias -> mapOf("event" to "identityAlias")
is SuperwallEvent.AppInstall -> mapOf("event" to "appInstall")
is SuperwallEvent.SessionStart -> mapOf("event" to "sessionStart")
is SuperwallEvent.Reset -> mapOf("event" to "reset")
is SuperwallEvent.Restore.Start -> mapOf("event" to "restoreStart")
is SuperwallEvent.Restore.Complete -> mapOf("event" to "restoreComplete")
is SuperwallEvent.Restore.Fail -> {
Expand Down
56 changes: 32 additions & 24 deletions example/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,36 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml

linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at https://dart.dev/lints.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
avoid_redundant_argument_values: true
avoid_relative_lib_imports: true
avoid_types_as_parameter_names: true
avoid_unnecessary_containers: true
avoid_unused_constructor_parameters: true
avoid_void_async: true
deprecated_consistency: true
directives_ordering: true
omit_local_variable_types: true
prefer_const_constructors: true
prefer_const_constructors_in_immutables: true
prefer_const_declarations: true
prefer_expression_function_bodies: true
prefer_final_in_for_each: true
prefer_final_locals: true
prefer_is_not_empty: true
prefer_is_not_operator: true
prefer_iterable_whereType: true
prefer_relative_imports: true
prefer_single_quotes: true
prefer_spread_collections: true
provide_deprecation_message: true
require_trailing_commas: false
unnecessary_brace_in_string_interps: true
unnecessary_lambdas: true
unnecessary_null_aware_assignments: true
unnecessary_null_checks: true
unnecessary_parenthesis: true
unnecessary_statements: true
unnecessary_string_escapes: true
unnecessary_string_interpolations: true
unnecessary_this: true
12 changes: 0 additions & 12 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
buildscript {
ext.kotlin_version = '1.7.10'
repositories {
google()
mavenCentral()
}

dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
Expand Down
2 changes: 1 addition & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-all.zip
3 changes: 2 additions & 1 deletion example/android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ pluginManagement {

plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.3.0" apply false
id "com.android.application" version "8.1.0" apply false
id "org.jetbrains.kotlin.android" version "1.8.0" apply false
}

include ":app", ':superwallkit_flutter'
21 changes: 8 additions & 13 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@ PODS:
- Flutter (1.0.0)
- integration_test (0.0.1):
- Flutter
- purchases_flutter (6.15.0):
- purchases_flutter (6.29.4):
- Flutter
- PurchasesHybridCommon (= 8.10.1)
- PurchasesHybridCommon (8.10.1):
- RevenueCat (= 4.31.9)
- RevenueCatUI (= 4.31.9)
- RevenueCat (4.31.9)
- RevenueCatUI (4.31.9):
- RevenueCat (= 4.31.9)
- PurchasesHybridCommon (= 10.9.0)
- PurchasesHybridCommon (10.9.0):
- RevenueCat (= 4.43.0)
- RevenueCat (4.43.0)
- SuperwallKit (3.6.6)
- superwallkit_flutter (0.0.1):
- Flutter
Expand All @@ -26,7 +23,6 @@ SPEC REPOS:
trunk:
- PurchasesHybridCommon
- RevenueCat
- RevenueCatUI
- SuperwallKit

EXTERNAL SOURCES:
Expand All @@ -42,10 +38,9 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
integration_test: 13825b8a9334a850581300559b8839134b124670
purchases_flutter: ce847b4848ccec17cadfb1a2e2a3ad1d3f681849
PurchasesHybridCommon: 170de77f83fd9cb570457157e92ea04c7aef8196
RevenueCat: aa3e439fb6282e7768609774a73c06ab87c3d9c3
RevenueCatUI: ef3f12dddf49d333a66a13f1d32c73ef1075ae95
purchases_flutter: a10ab0c4bb4effbc9b78be6513658ae659e67a20
PurchasesHybridCommon: 0e157d11d04fdfdd434b5c6d05acb58fd1cc9db8
RevenueCat: f7b90c52f4b7e322bc9e7adaf734030523534b06
SuperwallKit: e6db6c60f6dc95c3dc841525f84dc8504cfffb5a
superwallkit_flutter: f0094805f4346cfa08efd8f11c9be64df8b8d0a5

Expand Down
19 changes: 15 additions & 4 deletions example/lib/RCPurchaseController.dart
Original file line number Diff line number Diff line change
Expand Up @@ -254,19 +254,30 @@ extension CustomerInfoAdditions on CustomerInfo {
}

DateTime? getLatestTransactionPurchaseDate() {
Map<String, String> allPurchaseDates = this.allPurchaseDates;
Map<String, String?> allPurchaseDates = this.allPurchaseDates;

// Return null if there are no purchase dates
if (allPurchaseDates.entries.isEmpty) {
return null;
}

// Initialise the latestDate with the earliest possible date
DateTime latestDate = DateTime.fromMillisecondsSinceEpoch(0);

// Iterate over each entry in the map
allPurchaseDates.forEach((key, value) {
DateTime date = DateTime.parse(value);
if (date.isAfter(latestDate)) {
latestDate = date;
// Check if the value is not null
if (value != null) {
// Parse the date from the string value
DateTime date = DateTime.parse(value);
// Update the latestDate if the current date is after the latestDate
if (date.isAfter(latestDate)) {
latestDate = date;
}
}
});

// Return the latest date found
return latestDate;
}
}
Expand Down
Loading

0 comments on commit 2028246

Please sign in to comment.