pushdeer/ios/PushDeer-iOS/PushDeer/PushDeerApp.swift
hext 2136883536 支持微信登录, 修复一些bug:
支持微信登录, 支持同时绑定微信和苹果账号;
解决markdown标题文字显示不全的问题;
markdown中的链接支持内嵌浏览器打开;
增加是否使用内置浏览器的设置项;
改名输入框, 失去焦点的时候也保存;
2022-02-27 23:02:58 +08:00

47 lines
1.5 KiB
Swift

//
// PushDeerApp.swift
// PushDeer
//
// Created by HEXT on 2021/12/25.
//
import SwiftUI
@main
struct PushDeerApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
let store = AppState.shared
let persistenceController = PersistenceController.shared
var body: some Scene {
WindowGroup {
ContentView()
.onOpenURL(perform: { url in
print(#function, url)
#if !targetEnvironment(macCatalyst) && !APPCLIP && !SELFHOSTED
WXApi.handleOpen(url, delegate: WXDelegate.shared)
#endif
})
.onContinueUserActivity(NSUserActivityTypeBrowsingWeb, perform: { userActivity in
print(#function, userActivity.webpageURL as Any)
#if !targetEnvironment(macCatalyst) && !APPCLIP && !SELFHOSTED
WXApi.handleOpenUniversalLink(userActivity, delegate: WXDelegate.shared)
#endif
})
.onReceive(NotificationCenter.default.publisher(for: UIApplication.willEnterForegroundNotification)) { _ in
// ,
UIApplication.shared.applicationIconBadgeNumber = 0
// ,
if !AppState.shared.token.isEmpty {
Task {
let messageItems = try await HttpRequest.getMessages().messages
try MessageModel.saveAndUpdate(messageItems: messageItems)
}
}
}
.environmentObject(store)
.environment(\.managedObjectContext, persistenceController.container.viewContext)
}
}
}