|
@@ -9,21 +9,26 @@ import FirebaseCore
|
|
|
import GoogleMaps
|
|
import GoogleMaps
|
|
|
|
|
|
|
|
@main
|
|
@main
|
|
|
-class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate, MessagingDelegate {
|
|
|
|
|
- var window: UIWindow?
|
|
|
|
|
-
|
|
|
|
|
- var reactNativeDelegate: ReactNativeDelegate?
|
|
|
|
|
- var reactNativeFactory: RCTReactNativeFactory?
|
|
|
|
|
-
|
|
|
|
|
- func application(
|
|
|
|
|
|
|
+class AppDelegate: RCTAppDelegate, UIApplicationDelegate, UNUserNotificationCenterDelegate, MessagingDelegate {
|
|
|
|
|
+
|
|
|
|
|
+ override func application(
|
|
|
_ application: UIApplication,
|
|
_ application: UIApplication,
|
|
|
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
|
|
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
|
|
|
) -> Bool {
|
|
) -> Bool {
|
|
|
|
|
+ self.moduleName = "Strides"
|
|
|
|
|
+ self.dependencyProvider = RCTAppDependencyProvider()
|
|
|
|
|
+
|
|
|
|
|
+ // You can add your custom initial props in the dictionary below.
|
|
|
|
|
+ // They will be passed down to the ViewController used by React Native.
|
|
|
|
|
+ self.initialProps = [:]
|
|
|
GMSServices.provideAPIKey("AIzaSyAVzs860l2Iuu1zG80IT1Zu4w7OvbVmJ4g")
|
|
GMSServices.provideAPIKey("AIzaSyAVzs860l2Iuu1zG80IT1Zu4w7OvbVmJ4g")
|
|
|
FirebaseApp.configure()
|
|
FirebaseApp.configure()
|
|
|
Messaging.messaging().delegate = self
|
|
Messaging.messaging().delegate = self
|
|
|
-
|
|
|
|
|
- let delegate = ReactNativeDelegate()
|
|
|
|
|
|
|
+ let center = UNUserNotificationCenter.current()
|
|
|
|
|
+ center.delegate = self
|
|
|
|
|
+
|
|
|
|
|
+ return super.application(application, didFinishLaunchingWithOptions: launchOptions)
|
|
|
|
|
+ /*let delegate = ReactNativeDelegate()
|
|
|
let factory = RCTReactNativeFactory(delegate: delegate)
|
|
let factory = RCTReactNativeFactory(delegate: delegate)
|
|
|
delegate.dependencyProvider = RCTAppDependencyProvider()
|
|
delegate.dependencyProvider = RCTAppDependencyProvider()
|
|
|
|
|
|
|
@@ -41,7 +46,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
|
|
let center = UNUserNotificationCenter.current()
|
|
let center = UNUserNotificationCenter.current()
|
|
|
center.delegate = self
|
|
center.delegate = self
|
|
|
|
|
|
|
|
- return true
|
|
|
|
|
|
|
+ return true*/
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// MARK: - Linking (RN RCTLinkingManager)
|
|
// MARK: - Linking (RN RCTLinkingManager)
|
|
@@ -60,24 +65,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
|
|
restorationHandler: restorationHandler
|
|
restorationHandler: restorationHandler
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- /*func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) {
|
|
|
|
|
- guard let fcmToken = fcmToken else { return }
|
|
|
|
|
- // 1. 组装数据字典并发送本地通知
|
|
|
|
|
- let dataDict: [String: String] = ["token": fcmToken]
|
|
|
|
|
- NotificationCenter.default.post(
|
|
|
|
|
- name: Notification.Name("FCMToken"),
|
|
|
|
|
- object: nil,
|
|
|
|
|
- userInfo: dataDict
|
|
|
|
|
- )
|
|
|
|
|
-
|
|
|
|
|
- // 2. 将字符串转换为 Data (UTF-8)
|
|
|
|
|
- let deviceToken = fcmToken.data(using: .utf8)
|
|
|
|
|
-
|
|
|
|
|
- // 3. 将 Token 传递给 React Native Push Notification 插件
|
|
|
|
|
- // 注意:确保已在 Swift 桥接头文件 (Bridging Header) 中导入了 RNCPushNotificationIOS.h
|
|
|
|
|
- RNCPushNotificationIOS.didRegisterForRemoteNotifications(withDeviceToken: deviceToken)
|
|
|
|
|
- }*/
|
|
|
|
|
|
|
|
|
|
// MARK: - Push Notifications (RNCPushNotificationIOS)
|
|
// MARK: - Push Notifications (RNCPushNotificationIOS)
|
|
|
// Required to register for notifications
|
|
// Required to register for notifications
|
|
@@ -125,9 +112,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
|
|
) {
|
|
) {
|
|
|
completionHandler([.alert, .badge, .sound])
|
|
completionHandler([.alert, .badge, .sound])
|
|
|
}
|
|
}
|
|
|
-}
|
|
|
|
|
|
|
|
|
|
-class ReactNativeDelegate: RCTDefaultReactNativeFactoryDelegate {
|
|
|
|
|
override func sourceURL(for bridge: RCTBridge) -> URL? {
|
|
override func sourceURL(for bridge: RCTBridge) -> URL? {
|
|
|
self.bundleURL()
|
|
self.bundleURL()
|
|
|
}
|
|
}
|
|
@@ -140,3 +125,17 @@ class ReactNativeDelegate: RCTDefaultReactNativeFactoryDelegate {
|
|
|
#endif
|
|
#endif
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+/*class ReactNativeDelegate: RCTDefaultReactNativeFactoryDelegate {
|
|
|
|
|
+ override func sourceURL(for bridge: RCTBridge) -> URL? {
|
|
|
|
|
+ self.bundleURL()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ override func bundleURL() -> URL? {
|
|
|
|
|
+ #if DEBUG
|
|
|
|
|
+ RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
|
|
|
|
|
+ #else
|
|
|
|
|
+ Bundle.main.url(forResource: "main", withExtension: "jsbundle")
|
|
|
|
|
+ #endif
|
|
|
|
|
+ }
|
|
|
|
|
+}*/
|