Skip to content

Commit 47195bc

Browse files
authored
Merge pull request #232 from cuappdev/yana/siri-fix
Fix Siri Shortcut Donations
2 parents eeaff21 + 5a3165e commit 47195bc

2 files changed

Lines changed: 33 additions & 14 deletions

File tree

TCAT/AppDelegate.swift

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66
// Copyright © 2016 cuappdev. All rights reserved.
77
//
88

9-
import UIKit
9+
import Crashlytics
10+
import Fabric
1011
import Firebase
1112
import GoogleMaps
1213
import GooglePlaces
13-
import SwiftyJSON
14-
import Fabric
15-
import Crashlytics
14+
import Intents
1615
import SafariServices
16+
import SwiftyJSON
17+
import UIKit
1718
import WhatsNewKit
1819

1920
// This is used for app-specific preferences
@@ -78,7 +79,18 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
7879
let navigationController = showOnboarding ? OnboardingNavigationController(rootViewController: rootVC) :
7980
CustomNavigationController(rootViewController: rootVC)
8081

81-
// v1.3 Data Migration
82+
patchFunctions(rootVC: rootVC)
83+
84+
// Initalize window without storyboard
85+
self.window = UIWindow(frame: UIScreen.main.bounds)
86+
self.window!.rootViewController = navigationController
87+
self.window?.makeKeyAndVisible()
88+
89+
return true
90+
}
91+
92+
func patchFunctions(rootVC: UIViewController) {
93+
8294
if
8395
VersionStore.shared.savedAppVersion <= WhatsNew.Version(major: 1, minor: 2, patch: 1),
8496
let homeViewController = rootVC as? HomeViewController
@@ -92,13 +104,18 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
92104
Analytics.shared.log(payload)
93105
}
94106
}
95-
96-
// Initalize window without storyboard
97-
self.window = UIWindow(frame: UIScreen.main.bounds)
98-
self.window!.rootViewController = navigationController
99-
self.window?.makeKeyAndVisible()
100-
101-
return true
107+
108+
// v1.4.1 Delete Corrupted Shortcut Donations
109+
if VersionStore.shared.savedAppVersion <= WhatsNew.Version(major: 1, minor: 4, patch: 0) {
110+
print("Begin Deleting Corrupt Shortcut Donations")
111+
INInteraction.deleteAll { (error) in
112+
if let error = error {
113+
print("Failed to delete corrupt shortcut donations with error: \(error.localizedDescription )")
114+
} else {
115+
print("Succesfully deleted corrupt shortcut donations")
116+
}
117+
}
118+
}
102119
}
103120

104121
func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {

TCAT/Controllers/RouteOptionsViewController.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,8 +414,10 @@ class RouteOptionsViewController: UIViewController {
414414
if #available(iOS 12.0, *) {
415415
let intent = GetRoutesIntent()
416416
intent.searchTo = searchTo.name
417-
intent.latitude = String(describing: searchTo.latitude)
418-
intent.longitude = String(describing: searchTo.longitude)
417+
if let latitude = searchTo.latitude, let longitude = searchTo.longitude {
418+
intent.latitude = String(describing: latitude)
419+
intent.longitude = String(describing: longitude)
420+
}
419421
intent.suggestedInvocationPhrase = "Find bus to \(searchTo.name)"
420422
let interaction = INInteraction(intent: intent, response: nil)
421423
interaction.donate(completion: { (error) in

0 commit comments

Comments
 (0)