Skip to content

Commit

Permalink
Local Notification: schedule notification with Calendar
Browse files Browse the repository at this point in the history
  • Loading branch information
SajidHShanta committed Mar 4, 2023
1 parent 96eecdd commit 0542ec2
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,18 @@ class NotificationManager {

// trigger can be 3 types:
// - time
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 5.0, repeats: false)
// - calender
// let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 5.0, repeats: false)

// - calendar
var dateComponents = DateComponents()
dateComponents.hour = 0
dateComponents.minute = 18
dateComponents.weekday = 2 // every sunday 12 : 18 AM
// dateComponents.weekOfMonth
// dateComponents.weekOfYear

let trigger = UNCalendarNotificationTrigger(dateMatching: dateComponents, repeats: true)

// - location

let request = UNNotificationRequest(
Expand All @@ -46,7 +56,7 @@ class NotificationManager {

struct LocalNotification_Learn: View {
var body: some View {
VStack {
VStack(spacing: 50.0) {
Button("Request Permission") {
NotificationManager.instance.requestAuthorization()
}
Expand Down

0 comments on commit 0542ec2

Please sign in to comment.