Cannot find 'self' in scope; did you mean to use it in a type or extension context? I was programing notifications for my app and this error came up can anyone help me?
import SwiftUI
import UserNotificationsUI
import UserNotifications
struct Notification: View {
var body: some View {
Text("Hello, World!")
}
}
func chekForPermission() {
let notificaionCenter = UNUserNotificationCenter.current()
notificaionCenter.getNotificationSettings { settings in
switch settings.authorizationStatus {
case .authorized:
self.dispatchNotification()
case .denied:
return
case .notDetermined:
notificaionCenter.requestAuthorization(options: [.alert, .sound]) { didAllow, error in
if didAllow {
self.dispatchNotification()
}
}
default:
return
}
}
}
func dispatchNotification() {
}
struct Notification_Previews: PreviewProvider {
static var previews: some View {
Notification()
}
}