Skip to content
This repository has been archived by the owner on Nov 12, 2024. It is now read-only.

Commit

Permalink
Show notifications banners when app is open
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbanes committed Jun 30, 2024
1 parent 416ddd3 commit 77f0227
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion ios-app/Tivi/Tivi/TiviApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import FirebaseCrashlytics
import SwiftUI
import TiviKt

class AppDelegate: UIResponder, UIApplicationDelegate {
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate {
// property of the app's AppDelegate
var currentAuthorizationFlow: OIDExternalUserAgentSession?

Expand All @@ -27,7 +27,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
if !(FirebaseOptions.defaultOptions()?.apiKey?.isEmpty ?? true) {
FirebaseApp.configure()
}

// Set the UNUserNotificationCenter delegate
UNUserNotificationCenter.current().delegate = self

// Initiailize the AppInitializers
applicationComponent.initializers.initialize()

return true
}

Expand All @@ -44,6 +50,24 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

return false
}

func userNotificationCenter(
_: UNUserNotificationCenter,
willPresent _: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void
) {
// Show notification banners for notifications fired when the app is open
completionHandler([.banner])
}

func userNotificationCenter(
_: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void
) {
// TODO
completionHandler()
}
}

@main
Expand Down

0 comments on commit 77f0227

Please sign in to comment.