Skip to content

Commit 6490863

Browse files
committed
Release 1.7
1 parent d1abf8a commit 6490863

File tree

3 files changed

+61
-3
lines changed

3 files changed

+61
-3
lines changed

BranchLinkSimulator.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@
321321
"$(inherited)",
322322
"@executable_path/Frameworks",
323323
);
324-
MARKETING_VERSION = 1.6;
324+
MARKETING_VERSION = 1.7;
325325
PRODUCT_BUNDLE_IDENTIFIER = "io.branch.link-simulator";
326326
PRODUCT_NAME = "$(TARGET_NAME)";
327327
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
@@ -358,7 +358,7 @@
358358
"$(inherited)",
359359
"@executable_path/Frameworks",
360360
);
361-
MARKETING_VERSION = 1.6;
361+
MARKETING_VERSION = 1.7;
362362
PRODUCT_BUNDLE_IDENTIFIER = "io.branch.link-simulator";
363363
PRODUCT_NAME = "$(TARGET_NAME)";
364364
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";

BranchLinkSimulator/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
2020

2121
Branch.setAPIUrl("https://protected-api.branch.io")
2222
Branch.getInstance().enableLogging()
23-
23+
2424
// Retrieve or create the bls_session_id
2525
let blsSessionId: String
2626
if let savedId = UserDefaults.standard.string(forKey: "blsSessionId") {

BranchLinkSimulator/HomeView.swift

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ struct HomeView: View {
2121
@State private var showingEventActionSheet = false
2222
@State private var selectedEventType: BranchStandardEvent = .purchase
2323

24+
@State private var showingQRSheet = false
25+
@State private var qrCodeImage: UIImage? = nil
26+
2427
var body: some View {
2528
NavigationView {
2629
VStack {
@@ -73,6 +76,32 @@ struct HomeView: View {
7376
.background(Color.blue)
7477
.cornerRadius(8)
7578
}
79+
Button(action: createURL) {
80+
Label("Create Branch Link", systemImage: "link")
81+
.labelStyle(.titleAndIcon)
82+
.foregroundColor(.white)
83+
.padding()
84+
.frame(maxWidth: .infinity)
85+
.background(Color.blue)
86+
.cornerRadius(8)
87+
}
88+
Button(action: createQRCode) {
89+
Label("Create Branch QR Code", systemImage: "qrcode")
90+
.labelStyle(.titleAndIcon)
91+
.foregroundColor(.white)
92+
.padding()
93+
.frame(maxWidth: .infinity)
94+
.background(Color.blue)
95+
.cornerRadius(8)
96+
}
97+
.sheet(isPresented: $showingQRSheet) {
98+
if let qrImage = qrCodeImage {
99+
Image(uiImage: qrImage)
100+
.interpolation(.none)
101+
.resizable()
102+
.scaledToFit()
103+
}
104+
}
76105
}
77106
.headerProminence(.standard)
78107
.listRowSeparator(.hidden)
@@ -187,6 +216,35 @@ struct HomeView: View {
187216
}
188217
}
189218
}
219+
220+
func createURL() {
221+
let buo: BranchUniversalObject = BranchUniversalObject(canonicalIdentifier: "item/12345")
222+
let lp: BranchLinkProperties = BranchLinkProperties()
223+
224+
buo.getShortUrl(with: lp) { url, error in
225+
if (error != nil) {
226+
self.showToast(message: "Error creating link: \(error)")
227+
} else {
228+
self.showToast(message: "Created \(url ?? "N/A")")
229+
}
230+
}
231+
}
232+
233+
func createQRCode() {
234+
let buo: BranchUniversalObject = BranchUniversalObject(canonicalIdentifier: "item/12345")
235+
let lp: BranchLinkProperties = BranchLinkProperties()
236+
let qrCode = BranchQRCode()
237+
238+
qrCode.getAsImage(buo, linkProperties: lp) { image, error in
239+
if (error != nil) {
240+
self.showToast(message: "Error creating QR Code: \(error)")
241+
242+
} else {
243+
self.qrCodeImage = image
244+
self.showingQRSheet = true
245+
}
246+
}
247+
}
190248
}
191249

192250
extension View {

0 commit comments

Comments
 (0)