Tusker/Tusker/AppDelegate.swift

85 lines
2.6 KiB
Swift
Raw Normal View History

2018-08-16 02:27:48 +00:00
//
// AppDelegate.swift
// Tusker
//
// Created by Shadowfacts on 8/15/18.
// Copyright © 2018 Shadowfacts. All rights reserved.
//
import UIKit
2020-06-21 03:11:35 +00:00
import CrashReporter
2018-08-16 02:27:48 +00:00
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
2020-06-21 03:11:35 +00:00
static private(set) var crashReporter: PLCrashReporter!
static var pendingCrashReport: PLCrashReport?
2018-08-16 02:27:48 +00:00
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
2020-06-21 03:11:35 +00:00
#if !DEBUG
setupCrashReporter()
#endif
2019-09-19 20:55:15 +00:00
AppShortcutItem.createItems(for: application)
DispatchQueue.global(qos: .userInitiated).async {
AudioSessionHelper.disable()
AudioSessionHelper.setDefault()
}
2018-08-16 02:27:48 +00:00
return true
}
2020-06-21 03:11:35 +00:00
private func setupCrashReporter() {
let config = PLCrashReporterConfig(signalHandlerType: .BSD, symbolicationStrategy: .all)
AppDelegate.crashReporter = PLCrashReporter(configuration: config)
if AppDelegate.crashReporter.hasPendingCrashReport() {
let data = try! AppDelegate.crashReporter.loadPendingCrashReportDataAndReturnError()
AppDelegate.crashReporter.purgePendingCrashReport()
let report = try! PLCrashReport(data: data)
AppDelegate.pendingCrashReport = report
}
AppDelegate.crashReporter.enable()
}
2020-11-14 16:10:20 +00:00
override func buildMenu(with builder: UIMenuBuilder) {
super.buildMenu(with: builder)
if builder.system == .main {
MenuController.buildMainMenu(builder: builder)
}
}
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
let name = getSceneNameForActivity(options.userActivities.first)
return UISceneConfiguration(name: name, sessionRole: connectingSceneSession.role)
}
private func getSceneNameForActivity(_ activity: NSUserActivity?) -> String {
guard let activity = activity,
let type = UserActivityType(rawValue: activity.activityType) else {
return "main-scene"
}
switch type {
case .mainScene:
return "main-scene"
case .showConversation,
.showTimeline,
.checkNotifications,
.search,
.bookmarks,
.myProfile,
.showProfile:
return "auxiliary"
case .newPost:
return "compose"
}
}
2018-08-16 02:27:48 +00:00
}