Skip to content

Commit

Permalink
Merge pull request #20 from TartejBrothers/changes
Browse files Browse the repository at this point in the history
Fixed: Permission Issues
  • Loading branch information
TartejBrothers committed Jan 28, 2024
2 parents c7617e6 + a9e1c4d commit fbf24b6
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Dose Deck/ContentView.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import SwiftUI
import Firebase
import UserNotifications

struct ContentView: View {
@State private var email = ""
Expand Down Expand Up @@ -99,6 +100,8 @@ struct ContentView: View {
}
}
.onAppear {
requestNotificationPermission()

Auth.auth().addStateDidChangeListener { auth, user in
if user != nil {
userIsLogged.toggle()
Expand All @@ -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 {
Expand Down

0 comments on commit fbf24b6

Please sign in to comment.