-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAppDelegate.swift
62 lines (49 loc) · 2.21 KB
/
AppDelegate.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//
// AppDelegate.swift
// Boost
//
// Created by Dan Appel on 8/6/18.
// Copyright © 2018 Dan Appel. All rights reserved.
//
import UIKit
import UserNotifications
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Request permission for notifications
UNUserNotificationCenter.current()
.requestAuthorization(options: [.alert, .sound]) { (_, _) in }
UNUserNotificationCenter.current().delegate = self
if let centralsObj = launchOptions?[UIApplication.LaunchOptionsKey.bluetoothCentrals], let centrals = centralsObj as? [String] {
if centrals.contains(BluetoothManager.restorationId) {
// singleton so just getting it will initialize it
print("Woke up to restore manager \(BluetoothManager.restorationId)")
}
}
return true
}
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
print("App opened with url: \(url)")
SpotifyRemoteManager.shared.authCallback(app, open: url, options: options)
return true
}
/*
func applicationWillResignActive(_ application: UIApplication) {
if (rootViewController.appRemote.isConnected) {
rootViewController.appRemote.disconnect()
}
}
func applicationDidBecomeActive(_ application: UIApplication) {
if let _ = rootViewController.appRemote.connectionParameters.accessToken {
rootViewController.appRemote.connect()
}
}
*/
func userNotificationCenter(_: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
completionHandler()
}
func userNotificationCenter(_: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
completionHandler([.alert, .sound])
}
}