diff --git a/example/ios/ApphudSdkExample.xcodeproj/project.pbxproj b/example/ios/ApphudSdkExample.xcodeproj/project.pbxproj index d8bbdac..69a4679 100644 --- a/example/ios/ApphudSdkExample.xcodeproj/project.pbxproj +++ b/example/ios/ApphudSdkExample.xcodeproj/project.pbxproj @@ -309,6 +309,7 @@ TestTargetID = 13B07F861A680F5B00A75B9A; }; 13B07F861A680F5B00A75B9A = { + DevelopmentTeam = JLG6CF288G; LastSwiftMigration = 1120; }; 2D02E47A1E0B4A5D006451C7 = { @@ -617,7 +618,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = JLG6CF288G; ENABLE_BITCODE = NO; INFOPLIST_FILE = ApphudSdkExample/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 11.2; @@ -631,7 +632,7 @@ "-ObjC", "-lc++", ); - PRODUCT_BUNDLE_IDENTIFIER = com.touchzoo.livepapers; + PRODUCT_BUNDLE_IDENTIFIER = com.apphud.testapplication; PRODUCT_NAME = ApphudSdkExample; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; @@ -646,7 +647,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = JLG6CF288G; INFOPLIST_FILE = ApphudSdkExample/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 11.2; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -659,7 +660,7 @@ "-ObjC", "-lc++", ); - PRODUCT_BUNDLE_IDENTIFIER = com.touchzoo.livepapers; + PRODUCT_BUNDLE_IDENTIFIER = com.apphud.testapplication; PRODUCT_NAME = ApphudSdkExample; SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; diff --git a/example/ios/ApphudSdkExample/Info.plist b/example/ios/ApphudSdkExample/Info.plist index 16a92e9..dab6c5d 100644 --- a/example/ios/ApphudSdkExample/Info.plist +++ b/example/ios/ApphudSdkExample/Info.plist @@ -38,21 +38,7 @@ NSLocationWhenInUseUsageDescription - - UILaunchStoryboardName - LaunchScreen - UIRequiredDeviceCapabilities - - armv7 - - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UIViewControllerBasedStatusBarAppearance - + UIAppFonts AntDesign.ttf @@ -72,5 +58,19 @@ SimpleLineIcons.ttf Zocial.ttf + UILaunchStoryboardName + LaunchScreen + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UIViewControllerBasedStatusBarAppearance + diff --git a/ios/DataTransformer.swift b/ios/DataTransformer.swift index 6212325..bf6eb0c 100644 --- a/ios/DataTransformer.swift +++ b/ios/DataTransformer.swift @@ -9,14 +9,61 @@ import Foundation import StoreKit import ApphudSDK +extension SKProduct { + func toMap() -> NSDictionary { + let map: NSDictionary = [ + "id": productIdentifier, + "localizedTitle": localizedTitle, + "localizedDescription": localizedDescription, + "priceLocale": priceLocale.toMap(), + "price": price.floatValue, + "subscriptionPeriod": subscriptionPeriod?.toMap() as Any, + "introductoryPrice": introductoryPrice?.toMap() as Any, + //"isDownloadable": isDownloadable, + //"downloadContentLengths": downloadContentLengths.map {$0.intValue}, + //"contentVersion": contentVersion, + //"downloadContentVersion": downloadContentVersion + ] + return map + } +} + +extension Locale { + func toMap() -> NSDictionary { + return [ + "currencySymbol": currencySymbol ?? "", + "currencyCode": currencyCode ?? "", + "countryCode": regionCode ?? "", + ] + } +} + +@available(iOS 11.2, *) +extension SKProductSubscriptionPeriod { + func toMap() -> NSDictionary { + return [ + "numberOfUnits": numberOfUnits, + "unit": unit.rawValue + ] + } +} + +@available(iOS 11.2, *) +extension SKProductDiscount { + func toMap() -> NSDictionary { + return [ + "price": price.floatValue, + "priceLocale": ["":""], + "numberOfPeriods": numberOfPeriods, + "subscriptionPeriod": subscriptionPeriod.toMap(), + "paymentMode": paymentMode.rawValue, + ] + } +} + public class DataTransformer { public static func skProduct(product: SKProduct) -> NSDictionary { - return [ - "id": product.productIdentifier, - "price": product.price, - "regionCode": product.priceLocale.regionCode as Any, - "currencyCode": product.priceLocale.currencyCode as Any, - ]; + return product.toMap(); } public static func apphudSubscription(subscription: ApphudSubscription?) -> NSDictionary { diff --git a/src/ApphudSdkType.ts b/src/ApphudSdkType.ts index 0d628e5..eeaa3ec 100644 --- a/src/ApphudSdkType.ts +++ b/src/ApphudSdkType.ts @@ -83,17 +83,24 @@ export interface RestorePurchase { export interface ApphudProduct { id: string; price: string; + localizeTitle?: string; + localizedDescription?: string; + priceLocale?: { + currencySymbol: string; + currencyCode: string; + countryCode: string; + }; + subscriptionPeriod?: any; + introductoryPrice?: any; regionCode?: string; currencyCode?: string; description?: string; freeTrialPeriod?: string; - introductoryPrice?: string; introductoryPriceAmountMicros?: number; introductoryPriceCycles?: number; introductoryPricePeriod?: string; priceAmountMicros?: number; priceCurrencyCode?: string; - subscriptionPeriod?: string; title?: string; originalPrice?: string; type?: string;