Questions tagged [uiscenedelegate]

Methods you use to respond to life-cycle events occurring within a scene.

UISceneDelegate is available in UIKit since iOS 13.

From https://developer.apple.com/documentation/uikit/uiscenedelegate?language=objc

Use your UISceneDelegate object to manage life-cycle events in one instance of your app's user interface. This interface defines methods for responding to state transitions that affect the scene, including when the scene enters the foreground and becomes active, and when it enters the background. Use your delegate to provide appropriate behavior when these transitions occur. For example, finish critical tasks and quiet your app when it enters the background.

Do not create UISceneDelegate objects directly. Instead, specify the name of your custom delegate class as part of the configuration data for your scenes. You can specify this information in your app's Info.plist file, or in the UISceneConfiguration object you return from your app delegate's application:configurationForConnectingSceneSession:options: method.

156 questions
5
votes
1 answer

How to detect when a user terminates an app - Swift

Not sure why this is so challenging for me, but how can I detect when the user terminates the app? Because from what I'm seeing, Apple provides a lot of functions that might or might not be called when an app closes. func applicationWillTerminate(_…
Eric
  • 569
  • 4
  • 21
5
votes
0 answers

SceneDelegate.init() is being called when killing the app

I am experiencing some strange behavior in my app. Sometimes, when users kill the app, SceneDelegate.init() and scene(_:willConnectTo:options:) are called again which causes running the app init flow again. This results in some unexpected behavior…
4
votes
0 answers

iOS - sceneWillResignActive called twice when pulling the status bar to see notification center

I'm trying out iOS app states, and I came into a wired behavior when using sceneWillResignActive function inside SecenDelegate, this function works normally when I put the app in the background or when opening ControlCenter, but when I pull the…
4
votes
4 answers

Using UIScenes in iOS 13, how do I AirPlay Mirror a screen (seems to default to external display)

If I compile onto an iOS 12 device (doesn't use UIScene) and AirPlay Mirror to my Apple TV the app is mirrored as expected to the TV. On an iOS 13 device, it seems to treat it as an external display where it's formatted to fit the screen (but I have…
christianselig
  • 405
  • 4
  • 17
4
votes
0 answers

iOS 13 Issue: AppDelegate not triggering return of background music despite not supporting multiple windows

I have an app produced in Xcode prior to iOS 13. The app does not support multiple windows. While we have experienced weirdness with AppDelegate before, there seems to be more weirdness since iOS 13 was released, and I was hoping to see if others…
Mike Pandolfini
  • 532
  • 4
  • 17
3
votes
0 answers

Unexpected order of scene delegate method calls in Swift iOS app

I am encountering an unusual sequence of scene delegate method calls in my Swift iOS app. Specifically, sceneWillEnterForeground gets called before sceneDidEnterBackground, but with a different UIWindowScene instance. Here's the specific…
mmatiush
  • 31
  • 1
  • 4
3
votes
0 answers

KeyboardSceneDelegate: Animation styles were not empty on user driven presentation

I'm having problem with my app. When I tap on a TextField, trying to fill data, in the sheet that just show up, my app freezes and four errors appear on console: > [Assert] Animation styles expected to be empty on user driven > presentation.…
Vader20FF
  • 271
  • 2
  • 9
3
votes
1 answer

How to identify AppClips is launched by appclip card or by the user by searching the appclip in spotlight

I am working on an appclip, when I scan a QR code, appclip card gets shown and on click of open appclips gets launched and I performed a booking flow. Now next time if user comes to appclips using QR code, then I want to show an alert to user, that…
3
votes
1 answer

SwiftUI - Using @main to set the rootViewController

When using the SceneDelegate in SwiftUI, it was possible to create a function like the one below that could be used to set the view as shown here. However, in the latest version we now use a WindowsGroup. Is it possible to write a function that…
squarehippo10
  • 1,855
  • 1
  • 15
  • 45
3
votes
1 answer

Swift how to open specific viewcontroller from today extension when main app is not open

I have created a today extension with some UIButtons and I want to open a specific view controller when the user taps a button. It works right now when the main app is open, but when it is closed then it will only open the main app and dont navigate…
Mina
  • 133
  • 8
3
votes
2 answers

Track when user comes back to app or moves focus away from Mac Catalyst window

I would like to use the delegate methods of the UISceneSession lifecycle to help inform my Mac Catalyst app when the user moves their focus away from the app (window) and then comes back to the app (window). When the app first launches on Mac…
Cesare
  • 9,139
  • 16
  • 78
  • 130
3
votes
0 answers

Code in sceneDidDisconnect Delegate not being executed in Swift 5

I've got the below code in sceneDidDisconnect Delegate, letting the backend know that the user is no longer online when the app is being closed. The print statement gets executed but not the api call. I don't get why that is or how / where else I…
Bernhard Engl
  • 243
  • 1
  • 2
  • 12
3
votes
1 answer

Setting Up CoreData with SceneDelegate - unknown identifier 'window' error - iOS 13 onwards

I was trying to use the official apple documentation for Core Data. Found here. I also ran into a question which was related to my issue, right here on stack. I ran into an issue where, it kept saying that 'window' is not available in the context of…
Jay
  • 2,648
  • 4
  • 29
  • 58
3
votes
0 answers

Reload/refresh a scene after receive remote notification swiftUI

I have this problem. I'm receiving a notification from CloudKit using application:didReceiveRemoteNotification in AppDelegate. I'm able to receive the recordId, fetch it, and save it successfully. The problem is, the scene doesn't refresh. final…
amervil
  • 63
  • 3
3
votes
3 answers

iPadOS: Can I request another app to open in split screen?

I have written two Apps, let's call them A and B. When the user does a special action inside a fullscreen-displayed app A I want app B to automatically open in split screen next to app A. In this WWDC session, I learned that this is now possible…
heyfrank
  • 5,291
  • 3
  • 32
  • 46
1
2
3
10 11