Skip to content

Commit 6e9d17d

Browse files
committed
Fix Demo
1 parent 8c7abc5 commit 6e9d17d

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

Examples/Demo/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
5656
open url: URL,
5757
options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
5858
print("-- called application(_:open:options:) --")
59-
return Studyplus.shared.handle(appDelegateUrl: url)
59+
return Studyplus.shared.handle(url)
6060
}
6161
}

Examples/Demo/ViewController.swift

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,18 @@ class ViewController: UIViewController, StudyplusLoginDelegate {
6666

6767
self.resultLabel.text = ""
6868

69-
let recordAmount: StudyplusRecordAmount = StudyplusRecordAmount(amount: 10)
70-
let record: StudyplusRecord = StudyplusRecord(duration: duration,
71-
recordedAt: Date(),
72-
amount: recordAmount,
73-
comment: "Today, I studied like anything.")
74-
75-
Studyplus.shared.post(studyRecord: record, success: {
76-
77-
self.resultLabel.text = "Success to post your studyRecord to Studyplus App"
78-
79-
}, failure: { error in
80-
81-
self.resultLabel.text = "Error Code: \(error.code()), Message: \(error.message())"
69+
let record = StudyplusRecord(duration: Int(duration),
70+
amount: 10,
71+
comment: "Today, I studied like anything.",
72+
recordDatetime: Date())
73+
74+
Studyplus.shared.post(record, completion: { result in
75+
switch result {
76+
case .failure(let error):
77+
self.resultLabel.text = "Error Code: \(error)"
78+
case .success:
79+
self.resultLabel.text = "Success to post your studyRecord to Studyplus App"
80+
}
8281
})
8382
}
8483

@@ -96,9 +95,9 @@ class ViewController: UIViewController, StudyplusLoginDelegate {
9695
updateIsConnected()
9796
}
9897

99-
func studyplusDidFailToLogin(error: StudyplusError) {
98+
func studyplusDidFailToLogin(error: StudyplusLoginError) {
10099
print("-- Called studyplusDidFailToLogin --")
101-
resultLabel.text = "Error Code: \(error.code()), Message: \(error.message())"
100+
resultLabel.text = "Error Code: \(error)"
102101
updateIsConnected()
103102
}
104103

0 commit comments

Comments
 (0)