You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Would be nice to see an example of how to handle notifications, especially the silent ones that would trigger some data fetch/update.
Seeing as notifications are handled in AppDelegate callback, how would one go around hooking the logic from, say, Interactors.
So far, I see that it's possible to handle non-silent notifications in scene delegate like this:
classSceneDelegate:UIResponder,UIWindowSceneDelegate{func scene(
_ scene:UIScene,
willConnectTo session:UISceneSession,
options connectionOptions:UIScene.ConnectionOptions){
if let windowScene = scene as?UIWindowScene{letwindow=UIWindow(windowScene: windowScene)letenvironment=AppEnvironment.bootstrap(window: window)// This is UNNotificationResponse
if let notificationResponse = connectionOptions.notificationResponse {
window.makeKeyAndVisible()// do something with environment.container.interactorsreturn}
window.makeKeyAndVisible()}}}
And for silent notifications:
func application(
_ application:UIApplication,
didReceiveRemoteNotification userInfo:[AnyHashable:Any],
fetchCompletionHandler completionHandler:@escaping(UIBackgroundFetchResult)->()){
if let sceneDelegate = application.connectedScenes.first?.delegate as?SceneDelegate{
sceneDelegate.handleSilentNotification(userInfo)completionHandler(.newData)}completionHandler(.noData)}
Now that Xcode 11.4 allows to test notifications even on a simulator, it would be great to see the notification handling introduced to the example Clean SwiftUI Architecture app.
The text was updated successfully, but these errors were encountered:
@NeverwinterMoon , I've added handling of silent notifications and the notifications with a deep link. The project now contains a test .apns notification payload you can drag & drop onto the Simulator. Thank you for suggesting this!
@nalexn This is amazing! Thanks a lot for a quick response time and great work. This is definitely cleaner than my own implementation. Will try to find time today to check out how I can improve my code based on your work.
Would be nice to see an example of how to handle notifications, especially the silent ones that would trigger some data fetch/update.
Seeing as notifications are handled in AppDelegate callback, how would one go around hooking the logic from, say,
Interactors
.So far, I see that it's possible to handle non-silent notifications in scene delegate like this:
And for silent notifications:
Now that Xcode 11.4 allows to test notifications even on a simulator, it would be great to see the notification handling introduced to the example Clean SwiftUI Architecture app.
The text was updated successfully, but these errors were encountered: