<key>UIApplicationShortcutItems</key>
<array>
<dict>
<key>UIApplicationShortcutItemType</key>
<string>com.sap.example.showReports</string>
<key>UIApplicationShortcutItemIconType</key>
<string>UIApplicationShortcutIconTypeSearch</string>
<key>UIApplicationShortcutItemTitle</key>
<string>Show Reports</string>
<key>UIApplicationShortcutItemSubtitle</key>
<string>Show all available Reports</string>
</dict>
</array>
application(_:performActionFor:completionHandler:)
enum ShortcutItemType: String {
case CreateReport = "com.sap.example.showReports"
}
private var shortcutItemToProcess: UIApplicationShortcutItem?
func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {
// We save it here to later use it to process the navigation.
shortcutItemToProcess = shortcutItem
}
func applicationDidBecomeActive(_ application: UIApplication) {
// Get an instance of the Main.storyboard
let mainStoryBoard = UIStoryboard(name: "Main", bundle: nil)
// This will hold the view controllers
var masterViewController: UIViewController!
switch shortcutItemToProcess?.type {
case ShortcutItemType.ShowReport.rawValue:
logger.debug("Create Report Quick Action tapped.")
// Get an instance of the Report.storyboard and instantiate the ReportMaster view controller
let reportStoryBoard = UIStoryboard(name: "Report", bundle: nil)
let reportMasterViewController = reportStoryBoard.instantiateViewController(withIdentifier: "ReportMaster") as! ReportMasterViewController
reportMasterViewController.entitySetName = "ReportSet"
reportMasterViewController.navigationItem.title = "Report"
masterViewController = reportMasterViewController
default:
logger.debug("Default case for Quick Action.")
masterViewController = UIViewController()
}
// Prepare the navigation and execute it
let navController = mainStoryBoard.instantiateViewController(withIdentifier: "RightNavigationController") as! UINavigationController
navController.viewControllers = [masterViewController]
let splitViewController = window!.rootViewController
if splitViewController is UISplitViewController {
splitViewController?.showDetailViewController(navController, sender: nil)
}
// Reset the shortcut item so it's never processed twice.
shortcutItemToProcess = nil
}
guard let travelexpenseService = appDelegate.sessionManager.onboardingSession?.odataController.travelexpenseService else {
AlertHelper.displayAlert(with: "OData service is not reachable, please onboard again.", error: nil, viewController: self)
return
}
var appDelegate: AppDelegate { return (UIApplication.shared.delegate as! AppDelegate) }
/*
func requestEntities(completionHandler: @escaping (Error?) -> Void) {
self.loadEntitiesBlock! { entities, error in
if let error = error {
completionHandler(error)
return
}
self.entities = entities!
completionHandler(nil)
}
}
*/
func requestEntities(completionHandler: @escaping (Error?) -> Void) {
self.travelexpenseService.fetchReportSet { entities, error in
if let error = error {
completionHandler(error)
return
}
self.entities = entities!
completionHandler(nil)
}
}
func applicationWillResignActive(_ application: UIApplication) {
application.shortcutItems =
[UIApplicationShortcutItem(
type: ShortcutItemType.TakePhoto.rawValue,
localizedTitle: "Take a Picture",
localizedSubtitle: nil,
icon: UIApplicationShortcutIcon(type: .capturePhoto))]
}
enum ShortcutItemType: String {
case ShowReport = "com.sap.example.showReports"
case TakePhoto = "com.sap.example.takePhoto"
}
case ShortcutItemType.TakePhoto:
logger.debug("Take a picture.")
let takePictureViewController = mainStoryBoard.instantiateViewController(withIdentifier: "TakePicture") as! TakePictureViewController
masterViewController = takePictureViewController
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
37 | |
25 | |
17 | |
13 | |
7 | |
7 | |
7 | |
6 | |
6 | |
6 |