From a9e1c4d514687d40ca3813f339cbb9f21e3f6035 Mon Sep 17 00:00:00 2001 From: TartejBrothers Date: Sun, 28 Jan 2024 11:44:28 +0530 Subject: [PATCH] Fixed: Permission Issues --- Dose Deck/ContentView.swift | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Dose Deck/ContentView.swift b/Dose Deck/ContentView.swift index 7914bb0..363aadf 100644 --- a/Dose Deck/ContentView.swift +++ b/Dose Deck/ContentView.swift @@ -1,5 +1,6 @@ import SwiftUI import Firebase +import UserNotifications struct ContentView: View { @State private var email = "" @@ -99,6 +100,8 @@ struct ContentView: View { } } .onAppear { + requestNotificationPermission() + Auth.auth().addStateDidChangeListener { auth, user in if user != nil { userIsLogged.toggle() @@ -110,6 +113,16 @@ struct ContentView: View { } } + func requestNotificationPermission() { + UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { granted, error in + if granted { + print("Notification permission granted") + } else if let error = error { + print("Error requesting notification permission: \(error.localizedDescription)") + } + } + } + func login() { Auth.auth().signIn(withEmail: email, password: password) { result, error in if error != nil {