Skip to content
This repository was archived by the owner on Oct 12, 2025. It is now read-only.

Commit 3dee3aa

Browse files
authored
Merge pull request #96 from HackIllinois/dev
HI 2018 App v1.0.5 build(1)
2 parents ff8b97d + 3e761cd commit 3dee3aa

File tree

6 files changed

+136
-85
lines changed

6 files changed

+136
-85
lines changed

HackIllinois.xcodeproj/project.pbxproj

Lines changed: 72 additions & 68 deletions
Large diffs are not rendered by default.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//
2+
// HIPassService.swift
3+
// HackIllinois
4+
//
5+
// Created by Yasha Mostofi on 2/22/18.
6+
// Copyright © 2018 HackIllinois. All rights reserved.
7+
//
8+
9+
import Foundation
10+
import APIManager
11+
import SafariServices
12+
13+
final class HIPassService: HIBaseService {
14+
override static var baseURL: String {
15+
return "https://passgen.hackillinois.org/pkpass"
16+
}
17+
18+
static func getPass(with msg: String) -> APIRequest<Data> {
19+
let params: HTTPBody = [
20+
"message": msg
21+
]
22+
return APIRequest<Data>(service: self, endpoint: "", body: params, method: .POST)
23+
}
24+
25+
}
26+
27+
extension Data: APIReturnable {
28+
public init(from data: Data) throws {
29+
self = data
30+
}
31+
}

HackIllinois/Controllers/ViewControllers/HIUserDetailViewController.swift

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import Foundation
1010
import UIKit
11+
import PassKit
1112

1213
class HIUserDetailViewController: HIBaseViewController {
1314
// MARK: - Properties
@@ -87,6 +88,36 @@ extension HIUserDetailViewController {
8788
}
8889
userNameLabel.text = (user.name ?? user.identifier).uppercased()
8990
userInfoLabel.text = user.dietaryRestrictions?.displayText ?? "UNKNOWN DIETARY RESTRICTIONS"
91+
setupPass()
92+
}
93+
}
94+
95+
// MARK: - Passbook/Wallet support
96+
extension HIUserDetailViewController {
97+
func setupPass() {
98+
guard PKPassLibrary.isPassLibraryAvailable(),
99+
let user = HIApplicationStateController.shared.user,
100+
!UserDefaults.standard.bool(forKey: "HIAPPLICATION_PASS_PROMPTED_\(user.id)") else { return }
101+
let passString = "hackillinois://qrcode/user?id=\(user.id)&identifier=\(user.identifier)"
102+
HIPassService.getPass(with: passString)
103+
.onCompletion { result in
104+
switch result {
105+
case .success(let data):
106+
let pass = PKPass(data: data, error: nil)
107+
let vc = PKAddPassesViewController(pass: pass)
108+
DispatchQueue.main.async { [weak self] in
109+
if let strongSelf = self {
110+
UserDefaults.standard.set(true, forKey: "HIAPPLICATION_PASS_PROMPTED_\(user.id)")
111+
strongSelf.present(vc, animated: true, completion: nil)
112+
}
113+
}
114+
case .cancellation:
115+
break
116+
case .failure(let error):
117+
print(error)
118+
}
119+
}
120+
.perform()
90121
}
91122
}
92123

HackIllinois/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>APPL</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>1.0.4</string>
18+
<string>1.0.5</string>
1919
<key>CFBundleURLTypes</key>
2020
<array>
2121
<dict>

HackIllinois/UI/Themeable.swift

Lines changed: 0 additions & 15 deletions
This file was deleted.

Stickers/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<key>CFBundlePackageType</key>
1818
<string>XPC!</string>
1919
<key>CFBundleShortVersionString</key>
20-
<string>1.0.4</string>
20+
<string>1.0.5</string>
2121
<key>CFBundleVersion</key>
2222
<string>1</string>
2323
<key>NSExtension</key>

0 commit comments

Comments
 (0)