SceneDelegate.swift 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright 2020 Google LLC
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. import UIKit
  17. class SceneDelegate: UIResponder, UIWindowSceneDelegate {
  18. var window: UIWindow?
  19. func scene(_ scene: UIScene, willConnectTo session: UISceneSession,
  20. options connectionOptions: UIScene.ConnectionOptions) {
  21. // Use this method to optionally configure and attach the UIWindow `window` to the provided
  22. // UIWindowScene `scene`. If using a storyboard, the `window` property will automatically
  23. // be initialized and attached to the scene. This delegate does not imply the connecting
  24. // scene or session are new (see `application:configurationForConnectingSceneSession`
  25. // instead).
  26. guard let _ = (scene as? UIWindowScene) else { return }
  27. }
  28. func sceneDidDisconnect(_ scene: UIScene) {
  29. // Called as the scene is being released by the system.
  30. // This occurs shortly after the scene enters the background, or when its session is discarded.
  31. // Release any resources associated with this scene that can be re-created the next time the
  32. // scene connects. The scene may re-connect later, as its session was not necessarily
  33. // discarded (see `application:didDiscardSceneSessions` instead).
  34. }
  35. func sceneDidBecomeActive(_ scene: UIScene) {
  36. // Called when the scene has moved from an inactive state to an active state.
  37. // Use this method to restart any tasks that were paused (or not yet started) when the scene was
  38. // inactive.
  39. }
  40. func sceneWillResignActive(_ scene: UIScene) {
  41. // Called when the scene will move from an active state to an inactive state.
  42. // This may occur due to temporary interruptions (ex. an incoming phone call).
  43. }
  44. func sceneWillEnterForeground(_ scene: UIScene) {
  45. // Called as the scene transitions from the background to the foreground.
  46. // Use this method to undo the changes made on entering the background.
  47. }
  48. func sceneDidEnterBackground(_ scene: UIScene) {
  49. // Called as the scene transitions from the foreground to the background.
  50. // Use this method to save data, release shared resources, and store enough scene-specific state
  51. // information to restore the scene back to its current state.
  52. }
  53. }