From 10ee836f519ab9e459c49e4b396ffe86281235ba Mon Sep 17 00:00:00 2001 From: Aaron Date: Tue, 19 Jan 2021 08:30:25 -0500 Subject: [PATCH] Revert "Notification should open AlarmVC - It doesnt" This reverts commit d844e2720354904ce9681a295ea752f4e8fb5b38. --- ProjectClock.xcodeproj/project.pbxproj | 4 --- ProjectClock/AppDelegate.swift | 36 ++-------------------- ProjectClock/Base.lproj/Main.storyboard | 22 ++----------- ProjectClock/LiveAlarmViewController.swift | 29 ----------------- 4 files changed, 4 insertions(+), 87 deletions(-) delete mode 100644 ProjectClock/LiveAlarmViewController.swift diff --git a/ProjectClock.xcodeproj/project.pbxproj b/ProjectClock.xcodeproj/project.pbxproj index 3332e97..f2e7999 100644 --- a/ProjectClock.xcodeproj/project.pbxproj +++ b/ProjectClock.xcodeproj/project.pbxproj @@ -19,7 +19,6 @@ 4FF0684825A5F18800304E6B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4FF0684725A5F18800304E6B /* Assets.xcassets */; }; 4FF0684B25A5F18800304E6B /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4FF0684925A5F18800304E6B /* LaunchScreen.storyboard */; }; 7C5DAE9C25AF812200E44C52 /* clock.png in Resources */ = {isa = PBXBuildFile; fileRef = 7C5DAE9B25AF812200E44C52 /* clock.png */; }; - 7C5DAEA225AFD98600E44C52 /* LiveAlarmViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C5DAEA125AFD98600E44C52 /* LiveAlarmViewController.swift */; }; 7C83963625AF375B0027A94C /* NotificationLogic.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C83963525AF375B0027A94C /* NotificationLogic.swift */; }; 7C83963925AF68980027A94C /* TestingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C83963825AF68980027A94C /* TestingViewController.swift */; }; 7C83963C25AF6B6B0027A94C /* Alarm.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C83963B25AF6B6B0027A94C /* Alarm.swift */; }; @@ -40,7 +39,6 @@ 4FF0684A25A5F18800304E6B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 4FF0684C25A5F18800304E6B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 7C5DAE9B25AF812200E44C52 /* clock.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = clock.png; sourceTree = ""; }; - 7C5DAEA125AFD98600E44C52 /* LiveAlarmViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LiveAlarmViewController.swift; sourceTree = ""; }; 7C83962D25AF34F00027A94C /* ProjectClock.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = ProjectClock.entitlements; sourceTree = ""; }; 7C83962F25AF34F10027A94C /* HealthKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = HealthKit.framework; path = System/Library/Frameworks/HealthKit.framework; sourceTree = SDKROOT; }; 7C83963525AF375B0027A94C /* NotificationLogic.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationLogic.swift; sourceTree = ""; }; @@ -96,7 +94,6 @@ 4F509BD125AE22D100726227 /* Models.swift */, 7C83963825AF68980027A94C /* TestingViewController.swift */, 7C83963B25AF6B6B0027A94C /* Alarm.swift */, - 7C5DAEA125AFD98600E44C52 /* LiveAlarmViewController.swift */, ); path = ProjectClock; sourceTree = ""; @@ -187,7 +184,6 @@ 4F98955225A9260400F51321 /* Net.swift in Sources */, 4F8A607525A919E600D88DC3 /* Logic.swift in Sources */, 7C83963925AF68980027A94C /* TestingViewController.swift in Sources */, - 7C5DAEA225AFD98600E44C52 /* LiveAlarmViewController.swift in Sources */, 4FF0684325A5F18700304E6B /* AccountViewController.swift in Sources */, 4FF0683F25A5F18700304E6B /* AppDelegate.swift in Sources */, 4FF0684125A5F18700304E6B /* SceneDelegate.swift in Sources */, diff --git a/ProjectClock/AppDelegate.swift b/ProjectClock/AppDelegate.swift index 88e244a..7eed2de 100644 --- a/ProjectClock/AppDelegate.swift +++ b/ProjectClock/AppDelegate.swift @@ -6,7 +6,6 @@ // import UIKit -import UserNotifications @main class AppDelegate: UIResponder, UIApplicationDelegate { @@ -14,7 +13,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { - UNUserNotificationCenter.current().delegate = self // Override point for customization after application launch. return true } @@ -32,37 +30,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. // Use this method to release any resources that were specific to the discarded scenes, as they will not return. } + + } -extension AppDelegate: UNUserNotificationCenterDelegate { - - // This function will be called right after user tap on the notification - func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) { - - // retrieve the root view controller (which is a tab bar controller) - guard let rootViewController = (UIApplication.shared.connectedScenes.first?.delegate as? SceneDelegate)?.window?.rootViewController else { - return - } - - let storyboard = UIStoryboard(name: "Main", bundle: nil) - - // instantiate the view controller we want to show from storyboard - // root view controller is tab bar controller - // the selected tab is a navigation controller - // then we push the new view controller to it - if let alarmVC = storyboard.instantiateViewController(withIdentifier: "LiveAlarmViewController") as? LiveAlarmViewController, - let tabBarController = rootViewController as? UITabBarController, - let navController = tabBarController.selectedViewController as? UINavigationController { - - // we can modify variable of the new view controller using notification data - // (eg: title of notification) - //alarmVC.senderDisplayName = response.notification.request.content.title - // you can access custom data of the push notification by using userInfo property - // response.notification.request.content.userInfo - navController.pushViewController(alarmVC, animated: true) - } - - // tell the app that we have finished processing the user’s action / response - completionHandler() - } -} diff --git a/ProjectClock/Base.lproj/Main.storyboard b/ProjectClock/Base.lproj/Main.storyboard index e79761e..c30afe5 100644 --- a/ProjectClock/Base.lproj/Main.storyboard +++ b/ProjectClock/Base.lproj/Main.storyboard @@ -1,30 +1,15 @@ - + - + - - - - - - - - - - - - - - - @@ -616,9 +601,6 @@ - - - diff --git a/ProjectClock/LiveAlarmViewController.swift b/ProjectClock/LiveAlarmViewController.swift deleted file mode 100644 index 467011f..0000000 --- a/ProjectClock/LiveAlarmViewController.swift +++ /dev/null @@ -1,29 +0,0 @@ -// -// LiveAlarmViewController.swift -// ProjectClock -// -// Created by Aaron Saporito on 1/13/21. -// - -import UIKit - -class LiveAlarmViewController: UIViewController { - - override func viewDidLoad() { - super.viewDidLoad() - - // Do any additional setup after loading the view. - } - - - /* - // MARK: - Navigation - - // In a storyboard-based application, you will often want to do a little preparation before navigation - override func prepare(for segue: UIStoryboardSegue, sender: Any?) { - // Get the new view controller using segue.destination. - // Pass the selected object to the new view controller. - } - */ - -}