Skip to content

Commit 18d0871

Browse files
committed
AdaptyPlugin: add open_in to AdaptyUI.UserAction event
1 parent 20ad439 commit 18d0871

3 files changed

Lines changed: 20 additions & 3 deletions

File tree

Sources.AdaptyPlugin/Codable.AdaptyUI/AdaptyUI.Action+Encodable.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ extension AdaptyUI.Action: Encodable {
1313
private enum CodingKeys: String, CodingKey {
1414
case type
1515
case value
16+
case openIn = "open_in"
1617
}
1718

1819
public func encode(to encoder: Encoder) throws {
@@ -21,9 +22,10 @@ extension AdaptyUI.Action: Encodable {
2122
switch self {
2223
case .close:
2324
try container.encode("close", forKey: .type)
24-
case .openURL(let url):
25+
case .openURL(let url, let openIn):
2526
try container.encode("open_url", forKey: .type)
2627
try container.encode(url.absoluteString, forKey: .value)
28+
try container.encode(openIn, forKey: .openIn)
2729
case .custom(let id):
2830
try container.encode("custom", forKey: .type)
2931
try container.encode(id, forKey: .value)

Sources.AdaptyPlugin/Codable/AdaptyWebPresentation+Codable.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Adapty
99

10-
extension AdaptyWebPresentation: Decodable {
10+
extension AdaptyWebPresentation: Codable {
1111
public init(from decoder: any Decoder) throws {
1212
let container = try decoder.singleValueContainer()
1313
let stringValue = try container.decode(String.self)
@@ -20,4 +20,14 @@ extension AdaptyWebPresentation: Decodable {
2020
self = .externalBrowser
2121
}
2222
}
23+
24+
public func encode(to encoder: any Encoder) throws {
25+
var container = encoder.singleValueContainer()
26+
switch self {
27+
case .externalBrowser:
28+
try container.encode("browser_out_app")
29+
case .inAppBrowser:
30+
try container.encode("browser_in_app")
31+
}
32+
}
2333
}

Sources.AdaptyPlugin/cross_platform.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1455,9 +1455,14 @@ $defs:
14551455
- required: [type]
14561456
properties:
14571457
type: { type: string, const: ["close", "system_back"] }
1458+
- required: [type, value, open_in]
1459+
properties:
1460+
type: { type: string, const: "open_url" }
1461+
value: { type: string }
1462+
open_in: { $ref: "#/$defs/AdaptyWebPresentation" }
14581463
- required: [type, value]
14591464
properties:
1460-
type: { type: string, enum: ["open_url", "custom"] }
1465+
type: { type: string, const: "custom" }
14611466
value: { type: string }
14621467

14631468
AdaptyUI.CustomTagsValues: #request

0 commit comments

Comments
 (0)