Files
mao1/shenyan-app/ios/ShenYanApp/AppDelegate.swift
fyah d07d50dde5 更新 shenyan-app: APNs后台推送 + 通知点开进门 + cyberboss主动联系
- APNs: 修复AppDelegate推送回调转发(Bridging Header),设备token注册成功
- 通知: 点开系统通知直接进聊天屏, badge自动清零
- 主动联系: cyberboss守护进程, 3-60分钟随机判断, 按沈晏规则决定是否推送
- 气泡: 左右统一25%白色背景
- push-notification-ios包集成, Podfile更新

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-16 12:59:47 +08:00

64 lines
1.9 KiB
Swift

import UIKit
import React
import React_RCTAppDelegate
import ReactAppDependencyProvider
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
var reactNativeDelegate: ReactNativeDelegate?
var reactNativeFactory: RCTReactNativeFactory?
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
let delegate = ReactNativeDelegate()
let factory = RCTReactNativeFactory(delegate: delegate)
delegate.dependencyProvider = RCTAppDependencyProvider()
reactNativeDelegate = delegate
reactNativeFactory = factory
window = UIWindow(frame: UIScreen.main.bounds)
factory.startReactNative(
withModuleName: "ShenYanApp",
in: window,
launchOptions: launchOptions
)
// register for push notifications bypasses broken Turbo Module impl
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) { granted, _ in
if granted {
DispatchQueue.main.async { application.registerForRemoteNotifications() }
}
}
return true
}
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
RNCPushNotificationIOS.didRegisterForRemoteNotifications(withDeviceToken: deviceToken)
}
func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
RNCPushNotificationIOS.didFailToRegisterForRemoteNotificationsWithError(error)
}
}
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
}
}