Skip to content

Commit

Permalink
Merge pull request #26 from qonversion/release/3.1.0
Browse files Browse the repository at this point in the history
Release/3.1.0
  • Loading branch information
Maria-Bordunova authored Aug 12, 2021
2 parents 12cbabf + 1420902 commit a006060
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Editor/QonversionDependencies.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<dependencies>
<androidPackages>
<androidPackage spec="io.qonversion.android.sdk:sdk:3.0.0" />
<androidPackage spec="io.qonversion.android.sdk:sdk:3.1.0" />
<androidPackage spec="com.fasterxml.jackson.core:jackson-databind:2.11.1" />
<androidPackage spec="org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.61" />
</androidPackages>
<iosPods>
<iosPod name="Qonversion" version="2.13.3" />
<iosPod name="Qonversion" version="2.17.1" />
</iosPods>
</dependencies>
1 change: 1 addition & 0 deletions Runtime/Scripts/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ static class Constants
public const string KeyPrefix = "com.qonversion.keys";
public const string SourceKey = KeyPrefix + ".source";
public const string VersionKey = KeyPrefix + ".sourceVersion";
public const int SkuDetailsPriceRatio = 1000000;
}
}
46 changes: 43 additions & 3 deletions Runtime/Scripts/Models/Product.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,21 @@ public class Product
/// Available for Android only.
[CanBeNull] public readonly SkuDetails SkuDetails;

/// Store product title
[CanBeNull] public readonly string StoreTitle;

/// Store product description
[CanBeNull] public readonly string StoreDescription;

/// Price of the product
[CanBeNull] public readonly double Price;

/// Store Product currency code, such as USD
[CanBeNull] public readonly string CurrencyCode;

/// Formatted introductory price of a subscription, including its currency sign, such as €2.99
[CanBeNull] public readonly string PrettyIntroductoryPrice;

public Product(Dictionary<string, object> dict)
{
if (dict.TryGetValue("id", out object value)) QonversionId = value as string;
Expand All @@ -51,11 +66,31 @@ public Product(Dictionary<string, object> dict)
{
if (Application.platform == RuntimePlatform.Android)
{
if (value is Dictionary<string, object> skuDetails) SkuDetails = new SkuDetails(skuDetails);
if (value is Dictionary<string, object> skuDetails)
{
SkuDetails = new SkuDetails(skuDetails);

Price = (double)SkuDetails.PriceAmountMicros / Constants.SkuDetailsPriceRatio;
CurrencyCode = SkuDetails.PriceCurrencyCode;
StoreTitle = SkuDetails.Title;
StoreDescription = SkuDetails.Description;

string introPrice = SkuDetails.IntroductoryPrice;
PrettyIntroductoryPrice = (introPrice.Length != 0) ? introPrice : null;
}
}
else
{
if (value is Dictionary<string, object> skProduct) SkProduct = new SKProduct(skProduct);
if (value is Dictionary<string, object> skProduct)
{
SkProduct = new SKProduct(skProduct);

Price = double.Parse(SkProduct.Price);
CurrencyCode = SkProduct.CurrencyCode;
StoreTitle = SkProduct.LocalizedTitle;
StoreDescription = SkProduct.LocalizedDescription;
PrettyIntroductoryPrice = SkProduct.IntroductoryPrice.CurrencySymbol + SkProduct.IntroductoryPrice.Price;
}
}
}
}
Expand All @@ -69,7 +104,12 @@ public override string ToString()
$"{nameof(TrialDuration)}: {TrialDuration}, " +
$"{nameof(PrettyPrice)}: {PrettyPrice}, " +
$"{nameof(SkProduct)}: {SkProduct}, " +
$"{nameof(SkuDetails)}: {SkuDetails}";
$"{nameof(SkuDetails)}: {SkuDetails}" +
$"{nameof(StoreTitle)}: {StoreTitle}" +
$"{nameof(StoreDescription)}: {StoreDescription}" +
$"{nameof(Price)}: {Price}" +
$"{nameof(CurrencyCode)}: {CurrencyCode}" +
$"{nameof(PrettyIntroductoryPrice)}: {PrettyIntroductoryPrice}";
}

private QProductType FormatType(object productType) =>
Expand Down
5 changes: 4 additions & 1 deletion Runtime/Scripts/Models/SkProduct/SKProductDiscount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class SKProductDiscount
public readonly SKProductDiscountPaymentMode PaymentMode;
public readonly int NumberOfPeriods;
[CanBeNull] public readonly SKProductSubscriptionPeriod SubscriptionPeriod;
public readonly string CurrencySymbol;

public SKProductDiscount(Dictionary<string, object> dict)
{
Expand All @@ -22,6 +23,7 @@ public SKProductDiscount(Dictionary<string, object> dict)
if (dict.TryGetValue("localeIdentifier", out value)) LocaleIdentifier = value as string;
if (dict.TryGetValue("paymentMode", out value)) PaymentMode = FormatPaymentMode(value);
if (dict.TryGetValue("numberOfPeriods", out value)) NumberOfPeriods = Convert.ToInt32(value);
if (dict.TryGetValue("currencySymbol", out value)) CurrencySymbol = value as string;

if (dict.TryGetValue("subscriptionPeriod", out value))
{
Expand All @@ -38,7 +40,8 @@ public override string ToString()
$"{nameof(Price)}: {Price} , " +
$"{nameof(PaymentMode)}: {PaymentMode}, " +
$"{nameof(NumberOfPeriods)}: {NumberOfPeriods}, " +
$"{nameof(SubscriptionPeriod)}: {SubscriptionPeriod}";
$"{nameof(SubscriptionPeriod)}: {SubscriptionPeriod}" +
$"{nameof(CurrencySymbol)}: {CurrencySymbol}";
}

private SKProductDiscountType FormatDiscountType(object discountType) =>
Expand Down
2 changes: 1 addition & 1 deletion Runtime/Scripts/Qonversion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class Qonversion : MonoBehaviour
private const string OnOfferingsMethodName = "OnOfferings";
private const string OnEligibilitiesMethodName = "OnEligibilities";

private const string SdkVersion = "3.0.0";
private const string SdkVersion = "3.1.0";
private const string SdkSource = "unity";

private static IQonversionWrapper _Instance;
Expand Down
15 changes: 11 additions & 4 deletions Runtime/iOS/Plugins/Common/UtilityBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,16 @@ + (NSNumber *)convertProperty:(NSString *)propertyStr {
}

+ (NSDictionary *)convertError:(NSError *)error{
NSDictionary *errorDict = [@{
@"code": [@(error.code) stringValue],
@"message": [NSString stringWithFormat:@"%@. Domain: %@", error.localizedDescription, error.domain],
} mutableCopy];
NSString *errorMessage = [NSString stringWithFormat:@"%@. Domain: %@", error.localizedDescription, error.domain];
NSMutableDictionary *errorDict = [NSMutableDictionary new];
errorDict[@"code"] = @(error.code).stringValue;

NSString *debugMessage = error.userInfo[NSDebugDescriptionErrorKey];
if (debugMessage.length > 0) {
errorMessage = [NSString stringWithFormat:@"%@\nDebugInfo:%@", errorMessage, debugMessage];
}

errorDict[@"message"] = errorMessage;

NSMutableDictionary *result = [NSMutableDictionary new];
result[@"error"] = errorDict;
Expand Down Expand Up @@ -160,6 +166,7 @@ + (NSDictionary *)convertDiscount:(SKProductDiscount *)discount API_AVAILABLE(io
introductoryPrice[@"subscriptionPeriod"] = [subscriptionPeriod copy];

introductoryPrice[@"paymentMode"] = @(discount.paymentMode);
introductoryPrice[@"currencySymbol"] = discount.priceLocale.currencySymbol;

if (@available(iOS 12.2, *)) {
introductoryPrice[@"identifier"] = discount.identifier;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "com.qonversion.unity",
"displayName": "Qonversion",
"version": "3.0.0",
"version": "3.1.0",
"unity": "2018.3",
"description": "Empower your mobile app marketing and product decisions with precise subscription data.",
"author": {
Expand Down

0 comments on commit a006060

Please sign in to comment.