Completed dummy notification.
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
4FF0684625A5F18700304E6B /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4FF0684425A5F18700304E6B /* Main.storyboard */; };
|
4FF0684625A5F18700304E6B /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4FF0684425A5F18700304E6B /* Main.storyboard */; };
|
||||||
4FF0684825A5F18800304E6B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4FF0684725A5F18800304E6B /* Assets.xcassets */; };
|
4FF0684825A5F18800304E6B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4FF0684725A5F18800304E6B /* Assets.xcassets */; };
|
||||||
4FF0684B25A5F18800304E6B /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4FF0684925A5F18800304E6B /* LaunchScreen.storyboard */; };
|
4FF0684B25A5F18800304E6B /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4FF0684925A5F18800304E6B /* LaunchScreen.storyboard */; };
|
||||||
|
7C5DAE9925AF7DDE00E44C52 /* applelogo.png in Resources */ = {isa = PBXBuildFile; fileRef = 7C5DAE9825AF7DDE00E44C52 /* applelogo.png */; };
|
||||||
7C83963625AF375B0027A94C /* NotificationLogic.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C83963525AF375B0027A94C /* NotificationLogic.swift */; };
|
7C83963625AF375B0027A94C /* NotificationLogic.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C83963525AF375B0027A94C /* NotificationLogic.swift */; };
|
||||||
7C83963925AF68980027A94C /* TestingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C83963825AF68980027A94C /* TestingViewController.swift */; };
|
7C83963925AF68980027A94C /* TestingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C83963825AF68980027A94C /* TestingViewController.swift */; };
|
||||||
7C83963C25AF6B6B0027A94C /* Alarm.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C83963B25AF6B6B0027A94C /* Alarm.swift */; };
|
7C83963C25AF6B6B0027A94C /* Alarm.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C83963B25AF6B6B0027A94C /* Alarm.swift */; };
|
||||||
@@ -35,6 +36,7 @@
|
|||||||
4FF0684725A5F18800304E6B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
4FF0684725A5F18800304E6B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||||
4FF0684A25A5F18800304E6B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
|
4FF0684A25A5F18800304E6B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
|
||||||
4FF0684C25A5F18800304E6B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
4FF0684C25A5F18800304E6B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
|
7C5DAE9825AF7DDE00E44C52 /* applelogo.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = applelogo.png; path = ../../../Downloads/applelogo.png; sourceTree = "<group>"; };
|
||||||
7C83962D25AF34F00027A94C /* ProjectClock.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = ProjectClock.entitlements; sourceTree = "<group>"; };
|
7C83962D25AF34F00027A94C /* ProjectClock.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = ProjectClock.entitlements; sourceTree = "<group>"; };
|
||||||
7C83962F25AF34F10027A94C /* HealthKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = HealthKit.framework; path = System/Library/Frameworks/HealthKit.framework; sourceTree = SDKROOT; };
|
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 = "<group>"; };
|
7C83963525AF375B0027A94C /* NotificationLogic.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationLogic.swift; sourceTree = "<group>"; };
|
||||||
@@ -85,6 +87,7 @@
|
|||||||
4F8A607425A919E600D88DC3 /* Logic.swift */,
|
4F8A607425A919E600D88DC3 /* Logic.swift */,
|
||||||
7C83963525AF375B0027A94C /* NotificationLogic.swift */,
|
7C83963525AF375B0027A94C /* NotificationLogic.swift */,
|
||||||
4F98955125A9260400F51321 /* Net.swift */,
|
4F98955125A9260400F51321 /* Net.swift */,
|
||||||
|
7C5DAE9825AF7DDE00E44C52 /* applelogo.png */,
|
||||||
4F509BD125AE22D100726227 /* Models.swift */,
|
4F509BD125AE22D100726227 /* Models.swift */,
|
||||||
7C83963825AF68980027A94C /* TestingViewController.swift */,
|
7C83963825AF68980027A94C /* TestingViewController.swift */,
|
||||||
7C83963B25AF6B6B0027A94C /* Alarm.swift */,
|
7C83963B25AF6B6B0027A94C /* Alarm.swift */,
|
||||||
@@ -163,6 +166,7 @@
|
|||||||
4FF0684B25A5F18800304E6B /* LaunchScreen.storyboard in Resources */,
|
4FF0684B25A5F18800304E6B /* LaunchScreen.storyboard in Resources */,
|
||||||
4FF0684825A5F18800304E6B /* Assets.xcassets in Resources */,
|
4FF0684825A5F18800304E6B /* Assets.xcassets in Resources */,
|
||||||
4FF0684625A5F18700304E6B /* Main.storyboard in Resources */,
|
4FF0684625A5F18700304E6B /* Main.storyboard in Resources */,
|
||||||
|
7C5DAE9925AF7DDE00E44C52 /* applelogo.png in Resources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class TestingViewController: UIViewController {
|
|||||||
|
|
||||||
//Sends a test notification
|
//Sends a test notification
|
||||||
@IBAction func sendNotification(_ sender: Any) {
|
@IBAction func sendNotification(_ sender: Any) {
|
||||||
var alarm = Alarm(alarmTime: Date(), text: "Hello there!", wakeMethod: WVM(name: "walking", desc: "Walk"))
|
let alarm = Alarm(alarmTime: Date(), text: "Hello there!", wakeMethod: WVM(name: "walking", desc: "Walk"))
|
||||||
|
|
||||||
let content = UNMutableNotificationContent()
|
let content = UNMutableNotificationContent()
|
||||||
|
|
||||||
@@ -39,26 +39,24 @@ class TestingViewController: UIViewController {
|
|||||||
let today = Date()
|
let today = Date()
|
||||||
let formatter1 = DateFormatter()
|
let formatter1 = DateFormatter()
|
||||||
formatter1.dateStyle = .short
|
formatter1.dateStyle = .short
|
||||||
print(formatter1.string(from: today))
|
|
||||||
|
|
||||||
//Notification content
|
//Notification content
|
||||||
content.title = alarm.text
|
content.title = alarm.text
|
||||||
content.subtitle = formatter1.string(from: today)
|
content.subtitle = formatter1.string(from: today)
|
||||||
content.body = "Wake method: \(alarm.wakeMethod)"
|
content.body = "Wake method: \(alarm.wakeMethod.name)"
|
||||||
|
|
||||||
// 2
|
// Notification image content
|
||||||
let imageName = "applelogo"
|
let imageName = "applelogo"
|
||||||
guard let imageURL = Bundle.main.url(forResource: imageName, withExtension: "png") else { return }
|
guard let imageURL = Bundle.main.url(forResource: imageName, withExtension: "png") else { return }
|
||||||
|
|
||||||
let attachment = try! UNNotificationAttachment(identifier: imageName, url: imageURL, options: .none)
|
let attachment = try! UNNotificationAttachment(identifier: imageName, url: imageURL, options: .none)
|
||||||
|
|
||||||
content.attachments = [attachment]
|
content.attachments = [attachment]
|
||||||
|
|
||||||
// 3
|
|
||||||
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 0, repeats: false)
|
// Readies notification to be sent
|
||||||
|
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 5, repeats: false)
|
||||||
let request = UNNotificationRequest(identifier: "notification.id.01", content: content, trigger: trigger)
|
let request = UNNotificationRequest(identifier: "notification.id.01", content: content, trigger: trigger)
|
||||||
|
|
||||||
// 4
|
// Sends notification
|
||||||
UNUserNotificationCenter.current().add(request, withCompletionHandler: nil)
|
UNUserNotificationCenter.current().add(request, withCompletionHandler: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user