AppDelegate.swift 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import Expo
  2. import React
  3. import ReactAppDependencyProvider
  4. // @generated begin react-native-maps-import - expo prebuild (DO NOT MODIFY) sync-bee50fec513f89284e0fa3f5d935afdde33af98f
  5. #if canImport(GoogleMaps)
  6. import GoogleMaps
  7. #endif
  8. // @generated end react-native-maps-import
  9. @UIApplicationMain
  10. public class AppDelegate: ExpoAppDelegate {
  11. var window: UIWindow?
  12. var reactNativeDelegate: ExpoReactNativeFactoryDelegate?
  13. var reactNativeFactory: RCTReactNativeFactory?
  14. public override func application(
  15. _ application: UIApplication,
  16. didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
  17. ) -> Bool {
  18. let delegate = ReactNativeDelegate()
  19. let factory = ExpoReactNativeFactory(delegate: delegate)
  20. delegate.dependencyProvider = RCTAppDependencyProvider()
  21. reactNativeDelegate = delegate
  22. reactNativeFactory = factory
  23. bindReactNativeFactory(factory)
  24. #if os(iOS) || os(tvOS)
  25. window = UIWindow(frame: UIScreen.main.bounds)
  26. factory.startReactNative(
  27. withModuleName: "main",
  28. in: window,
  29. launchOptions: launchOptions)
  30. #endif
  31. // @generated begin react-native-maps-init - expo prebuild (DO NOT MODIFY) sync-4c371f87e557ea94a7c29bada06d77187db0d2ff
  32. #if canImport(GoogleMaps)
  33. GMSServices.provideAPIKey("AIzaSyAkfen-gfGOQyA9ui0_OjOS6TrA5-viBMI")
  34. #endif
  35. // @generated end react-native-maps-init
  36. return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  37. }
  38. // Linking API
  39. public override func application(
  40. _ app: UIApplication,
  41. open url: URL,
  42. options: [UIApplication.OpenURLOptionsKey: Any] = [:]
  43. ) -> Bool {
  44. return super.application(app, open: url, options: options) || RCTLinkingManager.application(app, open: url, options: options)
  45. }
  46. // Universal Links
  47. public override func application(
  48. _ application: UIApplication,
  49. continue userActivity: NSUserActivity,
  50. restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void
  51. ) -> Bool {
  52. let result = RCTLinkingManager.application(application, continue: userActivity, restorationHandler: restorationHandler)
  53. return super.application(application, continue: userActivity, restorationHandler: restorationHandler) || result
  54. }
  55. }
  56. class ReactNativeDelegate: ExpoReactNativeFactoryDelegate {
  57. // Extension point for config-plugins
  58. override func sourceURL(for bridge: RCTBridge) -> URL? {
  59. // needed to return the correct URL for expo-dev-client.
  60. bridge.bundleURL ?? bundleURL()
  61. }
  62. override func bundleURL() -> URL? {
  63. #if DEBUG
  64. return RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: ".expo/.virtual-metro-entry")
  65. #else
  66. return Bundle.main.url(forResource: "main", withExtension: "jsbundle")
  67. #endif
  68. }
  69. }