Forked from prafullakumar/handlepushSwiftui.swift
Last active
February 11, 2023 06:35
-
-
Save nth-chile/9b9536fc27ffa2e53d0a1e4ba1158aaf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
@main | |
struct ios14DemoApp: App { | |
@StateObject var notificationCenter = NotificationCenter() | |
var body: some Scene { | |
WindowGroup { | |
LocalNotificationDemoView(notificationCenter: notificationCenter) | |
} | |
} | |
} | |
class NotificationCenter: NSObject, ObservableObject { | |
override init() { | |
super.init() | |
UNUserNotificationCenter.current().delegate = self | |
} | |
// didReceive hook | |
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) { | |
// ... | |
} | |
} | |
struct LocalNotificationDemoView: View { | |
@ObservedObject var notificationCenter: NotificationCenter | |
var body: some View { | |
Button("schedule Notification") { | |
// UNUserNotificationCenter.current().add(...) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment