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

Show notifications banners when app is open #1924

Merged
merged 1 commit into from
Jun 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ excluded:
- ios-app/Tivi/UITests/SnapshotHelper.swift

strict: true

disabled_rules:
- todo
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
Loading