Skip to content

Commit

Permalink
add getProductsIntroductoryOfferEligibility to iOS Bridge
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksei-valiano committed Sep 21, 2023
1 parent 9d12eed commit 081b608
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
17 changes: 16 additions & 1 deletion Assets/AdaptySDK/Plugins/iOS/Source/AdaptyUnityPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import Adapty
}
}

@objc public func getPaywallProducts(_ paywallJson: String, fetchPolicy: String, completion: JSONStringCompletion? = nil) {
@objc public func getPaywallProducts(_ paywallJson: String, completion: JSONStringCompletion? = nil) {
let paywall: AdaptyPaywall
do {
paywall = try AdaptyUnityPlugin.decode(AdaptyPaywall.self, from: paywallJson)
Expand All @@ -71,6 +71,21 @@ import Adapty
}
}

@objc public func getProductsIntroductoryOfferEligibility(_ arrayJson: String, completion: JSONStringCompletion? = nil) {
let vendorProductIds: [String]
do {
vendorProductIds = try AdaptyUnityPlugin.decode([String].self, from: arrayJson)
} catch {
let error = PluginError.decodingFailed(error)
completion?(AdaptyUnityPlugin.encodeToString(result: error))
return
}

Adapty.getProductsIntroductoryOfferEligibility(vendorProductIds: vendorProductIds) { result in
completion?(AdaptyUnityPlugin.encodeToString(result: result))
}
}

@objc public func getProfile(completion: JSONStringCompletion? = nil) {
Adapty.getProfile { result in
completion?(AdaptyUnityPlugin.encodeToString(result: result))
Expand Down
15 changes: 11 additions & 4 deletions Assets/AdaptySDK/Plugins/iOS/Source/AdaptyUnityPluginBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -85,21 +85,28 @@ void AdaptyUnity_logout(UnityAction callback) {
void AdaptyUnity_getPaywall(const char *paywallId, const char *locale, UnityAction callback) {
[[AdaptyUnityPlugin shared]
getPaywall:cstringToString(paywallId)
locale:cstringToString(locale)
locale:cstringToString(locale)
completion:^(NSString *_Nullable response) {
SendCallbackToUnity(callback, response);
}];
}

void AdaptyUnity_getPaywallProducts(const char *paywall, const char *fetchPolicy, UnityAction callback) {
void AdaptyUnity_getPaywallProducts(const char *paywall, UnityAction callback) {
[[AdaptyUnityPlugin shared]
getPaywallProducts:cstringToString(paywall)
fetchPolicy:cstringToString(fetchPolicy)
completion:^(NSString *_Nullable response) {
SendCallbackToUnity(callback, response);
}];
}

void AdaptyUnity_getProductsIntroductoryOfferEligibility(const char *products, UnityAction callback) {
[[AdaptyUnityPlugin shared]
getProductsIntroductoryOfferEligibility:cstringToString(products)
completion:^(NSString *_Nullable response) {
SendCallbackToUnity(callback, response);
}];
}

void AdaptyUnity_getProfile(UnityAction callback) {
[[AdaptyUnityPlugin shared]
getProfileWithCompletion:^(NSString *_Nullable response) {
Expand Down Expand Up @@ -167,7 +174,7 @@ void AdaptyUnity_updateAttribution(const char *attributions, const char *source,
void AdaptyUnity_setVariationForTransaction(const char *parameters, UnityAction callback) {
[[AdaptyUnityPlugin shared]
setVariationForTransaction:cstringToString(parameters)
completion:^(NSString *_Nullable response) {
completion:^(NSString *_Nullable response) {
SendCallbackToUnity(callback, response);
}];
}
Expand Down

0 comments on commit 081b608

Please sign in to comment.