Explore Enterprise Education Gitee Premium Gitee AI AI teammates
Fetch the repository succeeded.
Donate
Please sign in before you donate.
Scan WeChat QR to Pay
Cancel
Complete
Prompt
Switch to Alipay.
OK
Cancel
1 Star 1 Fork 4K

java8dj/O2OA

Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
Already have an account? Sign in
文件
master
Branches (1)
Tags (1)
master
v4.12.27
master
Branches (1)
Tags (1)
master
v4.12.27
Clone or Download
Clone/Download
Prompt
To download the code, please copy the following command and execute it in the terminal
To ensure that your submitted code identity is correctly recognized by Gitee, please execute the following command.
When using the SSH protocol for the first time to clone or push code, follow the prompts below to complete the SSH configuration.
1 Generate RSA keys.
2 Obtain the content of the RSA public key and configure it in SSH Public Keys
To use SVN on Gitee, please visit the usage guide
When using the HTTPS protocol, the command line will prompt for account and password verification as follows. For security reasons, Gitee recommends configure and use personal access tokens instead of login passwords for cloning, pushing, and other operations.
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # Private Token
master
Branches (1)
Tags (1)
master
v4.12.27
O2OA
/
o2ios
/
O2Platform
/
common
/
AppDelegate.swift
O2OA
/
o2ios
/
O2Platform
/
common
/
AppDelegate.swift
AppDelegate.swift 16.26 KB
Copy Edit Raw Blame History
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384
//
// AppDelegate.swift
// O2Platform
//
// Created by 刘振兴 on 16/6/14.
// Copyright © 2016年 zoneland. All rights reserved.
//
import UIKit
import CocoaLumberjack
import AlamofireNetworkActivityIndicator
import EZSwiftExtensions
import UserNotifications
import O2OA_Auth_SDK
import Flutter
import IQKeyboardManagerSwift
let isProduction = true
@UIApplicationMain
class AppDelegate: FlutterAppDelegate, JPUSHRegisterDelegate, UNUserNotificationCenterDelegate {
var _mapManager: BMKMapManager?
//中心服务器节点类
public static let o2Collect = O2Collect()
//中心服务器绑定数据信息
public static var deviceData = CollectDeviceData()
//网络监听
public let o2ReachabilityManager = O2ReachabilityManager.sharedInstance
// flutter engine
var flutterEngine : FlutterEngine?
override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let themeName = AppConfigSettings.shared.themeName
if themeName != "" {
//主题
print("主题色:\(themeName)")
O2ThemeManager.setTheme(plistName: themeName, path: .mainBundle)
}else {
O2ThemeManager.setTheme(plistName: "red", path: .mainBundle)
}
//搜索框
UISearchBar.appearance().theme_barTintColor = ThemeColorPicker(keyPath: "Base.base_color")
UISearchBar.appearance().tintColor = UIColor.white
UITextField.appearance(whenContainedInInstancesOf: [UISearchBar.self]).theme_tintColor = ThemeColorPicker(keyPath: "Base.base_color")
//启动日志管理器
O2Logger.startLogManager()
//日志文件
_ = O2Logger.getLogFiles()
O2Logger.debug("设置运行版本==========,\(PROJECTMODE)")
//网络检查
o2ReachabilityManager.startListening()
//Alamofire
NetworkActivityIndicatorManager.shared.isEnabled = true
//设置一个是否第一授权的标志
if #available(iOS 10.0, *){
let center = UNUserNotificationCenter.current()
center.delegate = self
let options:UNAuthorizationOptions = [.badge,.alert,.sound]
center.requestAuthorization(options: options, completionHandler: { (granted, err) in
if granted == true {
//记录已经打开授权
//print("aaaaaaaaaaaa")
AppConfigSettings.shared.notificationGranted = true
AppConfigSettings.shared.firstGranted = true
NotificationCenter.default.post(name: NSNotification.Name.init("SETTING_NOTI"), object: nil)
}else{
//记录禁用授权
AppConfigSettings.shared.notificationGranted = false
AppConfigSettings.shared.firstGranted = true
NotificationCenter.default.post(name: NSNotification.Name.init("SETTING_NOTI"), object: nil)
}
})
}else{
let types:UIUserNotificationType = [.badge,.alert,.sound]
let setting = UIUserNotificationSettings(types: types, categories: nil)
UIApplication.shared.registerUserNotificationSettings(setting)
}
//UMessage.setLogEnabled(true)
//蒲公英
let pgyAppId = PGY_APP_ID
PgyManager.shared().themeColor = base_color
PgyManager.shared().feedbackActiveType = KPGYFeedbackActiveType.pgyFeedbackActiveTypeThreeFingersPan
PgyManager.shared().start(withAppId: pgyAppId)
PgyUpdateManager.sharedPgy().start(withAppId: pgyAppId)
if UIDevice.deviceModelReadable() == "Simulator" {
AppDelegate.deviceData.name = UIDevice.idForVendor()!
}
//Buglyy异常上报
Bugly.start(withAppId: BUGLY_ID)
//JPush
_setupJPUSH()
JPUSHService.setup(withOption: launchOptions, appKey: JPUSH_APP_KEY, channel: JPUSH_channel, apsForProduction: isProduction)
JMessage.setupJMessage(launchOptions, appKey: JPUSH_APP_KEY, channel: JPUSH_channel, apsForProduction: isProduction, category: nil, messageRoaming: true)
_setupJMessage()
_mapManager = BMKMapManager()
BMKMapManager.setCoordinateTypeUsedInBaiduMapSDK(BMK_COORDTYPE_BD09LL)
_mapManager?.start(BAIDU_MAP_KEY, generalDelegate: nil)
JPUSHService.registrationIDCompletionHandler { (resCode, registrationID) in
if resCode == 0 {
O2Logger.debug("registrationID获取成功\(registrationID ?? "")")
//AppDelegate.deviceData.name = registrationID
O2AuthSDK.shared.setDeviceToken(token: registrationID ?? "registrationIDerror0x0x")
}else{
O2Logger.debug("registrationID获取失败,code:\(resCode)")
O2AuthSDK.shared.setDeviceToken(token: registrationID ?? "registrationIDerror0x0x")
}
}
// OOPlusButtonSubclass.register()
OOTabBarHelper.initTabBarStyle()
//
IQKeyboardManager.shared.enable = true
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
// MARK:- private func Jpush
private func _setupJPUSH() {
if #available(iOS 10, *) {
let entity = JPUSHRegisterEntity()
entity.types = NSInteger(UNAuthorizationOptions.alert.rawValue) |
NSInteger(UNAuthorizationOptions.sound.rawValue) |
NSInteger(UNAuthorizationOptions.badge.rawValue)
JPUSHService.register(forRemoteNotificationConfig: entity, delegate: self)
} else {
// ios 8 以前 categories 必须为nil
JPUSHService.register(
forRemoteNotificationTypes: UIRemoteNotificationType.badge.rawValue |
UIRemoteNotificationType.sound.rawValue |
UIRemoteNotificationType.alert.rawValue,
categories: nil)
}
}
// MARK: - private func
private func _setupJMessage() {
JMessage.add(self as! JMessageDelegate, with: nil)
// JMessage.setLogOFF()
JMessage.setLogOFF()
// if #available(iOS 8, *) {
// JMessage.register(
// forRemoteNotificationTypes: UIUserNotificationType.badge.rawValue |
// UIUserNotificationType.sound.rawValue |
// UIUserNotificationType.alert.rawValue,
// categories: nil)
// } else {
// // iOS 8 以前 categories 必须为nil
// JMessage.register(
// forRemoteNotificationTypes: UIRemoteNotificationType.badge.rawValue |
// UIRemoteNotificationType.sound.rawValue |
// UIRemoteNotificationType.alert.rawValue,
// categories: nil)
// }
}
override func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
super.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)
// let deviceId = deviceToken.hexString
// if !deviceId.isEmpty {
// AppDelegate.deviceData.name = deviceId
// }else{
// AppDelegate.deviceData.name = "104C9F7F-7403-4B3E-B6A2-C222C82074FF"
// }
O2Logger.debug("get the deviceToken \(deviceToken)")
NotificationCenter.default.post(name: Notification.Name(rawValue: "DidRegisterRemoteNotification"), object: deviceToken)
JPUSHService.registerDeviceToken(deviceToken)
JMessage.registerDeviceToken(deviceToken)
}
override func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
DDLogDebug("open url :\(url.absoluteString)")
return true
}
override func application(_ application: UIApplication, didRegister notificationSettings: UIUserNotificationSettings) {
if notificationSettings.types.rawValue == 0 {
AppConfigSettings.shared.notificationGranted = false
AppConfigSettings.shared.firstGranted = true
NotificationCenter.default.post(name: NSNotification.Name.init("SETTING_NOTI"), object: nil)
}else{
AppConfigSettings.shared.notificationGranted = true
AppConfigSettings.shared.firstGranted = true
NotificationCenter.default.post(name: NSNotification.Name.init("SETTING_NOTI"), object: nil)
}
}
override func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
DDLogError(error.localizedDescription)
AppDelegate.deviceData.name = "104C9F7F-7403-4B3E-B6A2-C222C82074FF"
}
override func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) {
JPUSHService.handleRemoteNotification(userInfo)
O2Logger.debug("收到通知,\(userInfo)")
NotificationCenter.default.post(name: Notification.Name(rawValue: "AddNotificationCount"), object: nil) //把 要addnotificationcount
}
override func application(_ application: UIApplication, didReceive notification: UILocalNotification) {
JPUSHService.showLocalNotification(atFront: notification, identifierKey: nil)
}
override func applicationWillEnterForeground(_ application: UIApplication) {
application.applicationIconBadgeNumber = 0
application.cancelAllLocalNotifications()
}
override func applicationDidBecomeActive(_ application: UIApplication) {
if UIDevice.deviceModelReadable() != "Simulator" {
PgyUpdateManager.sharedPgy().checkUpdate(withDelegete: self, selector: #selector(updateVersion(_:)))
}
}
deinit {
o2ReachabilityManager.stopListening()
}
@available(iOS 10.0, *)
func jpushNotificationCenter(_ center: UNUserNotificationCenter!, didReceive response: UNNotificationResponse!, withCompletionHandler completionHandler: (() -> Void)!) {
let userInfo = response.notification.request.content.userInfo
let request = response.notification.request // 收到推送的请求
let content = request.content // 收到推送的消息内容
let badge = content.badge // 推送消息的角标
let body = content.body // 推送消息体
let sound = content.sound // 推送消息的声音
let subtitle = content.subtitle // 推送消息的副标题
let title = content.title // 推送消息的标题
if (response.notification.request.trigger?.isKind(of: UNPushNotificationTrigger.self))! {
JPUSHService.handleRemoteNotification(userInfo)
}else{
//判断为本地通知
O2Logger.debug("iOS10 前台收到本地通知:{\nbody:\(body),\ntitle:\(title),\nsubtitle:\(subtitle),\nbadge:\(badge ?? 0),\nsound:\(sound.debugDescription)")
}
completionHandler()
}
@available(iOS 10.0, *)
func jpushNotificationCenter(_ center: UNUserNotificationCenter!, willPresent notification: UNNotification!,
withCompletionHandler completionHandler: ((Int) -> Void)!) {
let userInfo = notification.request.content.userInfo
let request = notification.request // 收到推送的请求
let content = request.content // 收到推送的消息内容
let badge = content.badge // 推送消息的角标
let body = content.body // 推送消息体
let sound = content.sound // 推送消息的声音
let subtitle = content.subtitle // 推送消息的副标题
let title = content.title // 推送消息的标题
if (notification.request.trigger?.isKind(of: UNPushNotificationTrigger.self))! {
JPUSHService.handleRemoteNotification(userInfo)
}else{
//判断为本地通知
O2Logger.debug("iOS10 前台收到本地通知:{\nbody:\(body),\ntitle:\(title),\nsubtitle:\(subtitle),\nbadge:\(badge ?? 0),\nsound:\(sound.debugDescription)")
}
completionHandler(Int(UNNotificationPresentationOptions.alert.rawValue|UNNotificationPresentationOptions.badge.rawValue|UNNotificationPresentationOptions.sound.rawValue))
}
@available(iOS 10.0, *)
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
}
@available(iOS 10.0, *)
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
}
@objc private func updateVersion(_ response:AnyObject?){
O2Logger.debug("update be callbacked")
if let obj = response {
//ProgressHUD.dismiss()
//print(obj)
let appURLString = (obj as! NSDictionary)["downloadURL"]
if let appURL = URL(string: appURLString as! String) {
if UIApplication.shared.canOpenURL(appURL) {
if UIApplication.shared.openURL(appURL) {
PgyUpdateManager.sharedPgy().updateLocalBuildNumber()
}
}
}
}
}
}
//MARK: - JMessage Delegate
extension AppDelegate: JMessageDelegate {
func onDBMigrateStart() {
// self.showMessage(title: "数据库升级中")
}
func onDBMigrateFinishedWithError(_ error: Error!) {
// self.showSuccess(title: "数据库升级完成")
}
func onReceive(_ event: JMSGNotificationEvent!) {
switch event.eventType {
case .receiveFriendInvitation, .acceptedFriendInvitation, .declinedFriendInvitation:
cacheInvitation(event: event)
case .loginKicked, .serverAlterPassword, .userLoginStatusUnexpected:
_logout()
case .deletedFriend, .receiveServerFriendUpdate:
NotificationCenter.default.post(name: Notification.Name(rawValue: kUpdateFriendList), object: nil)
default:
break
}
}
private func cacheInvitation(event: JMSGNotificationEvent) {
let friendEvent = event as! JMSGFriendNotificationEvent
let user = friendEvent.getFromUser()
let reason = friendEvent.getReason()
let info = JCVerificationInfo.create(username: user!.username, nickname: user?.nickname, appkey: user!.appKey!, resaon: reason, state: JCVerificationType.wait.rawValue)
switch event.eventType {
case .receiveFriendInvitation:
info.state = JCVerificationType.receive.rawValue
JCVerificationInfoDB.shareInstance.insertData(info)
case .acceptedFriendInvitation:
info.state = JCVerificationType.accept.rawValue
JCVerificationInfoDB.shareInstance.updateData(info)
NotificationCenter.default.post(name: Notification.Name(rawValue: kUpdateFriendList), object: nil)
case .declinedFriendInvitation:
info.state = JCVerificationType.reject.rawValue
JCVerificationInfoDB.shareInstance.updateData(info)
default:
break
}
if UserDefaults.standard.object(forKey: kUnreadInvitationCount) != nil {
let count = UserDefaults.standard.object(forKey: kUnreadInvitationCount) as! Int
UserDefaults.standard.set(count + 1, forKey: kUnreadInvitationCount)
} else {
UserDefaults.standard.set(1, forKey: kUnreadInvitationCount)
}
NotificationCenter.default.post(name: Notification.Name(rawValue: kUpdateVerification), object: nil)
}
func _logout() {
JMSGUser.logout(nil)
JCVerificationInfoDB.shareInstance.queue = nil
UserDefaults.standard.removeObject(forKey: kCurrentUserName)
// let alertView = UIAlertView(title: "您的账号在其它设备上登录", message: "", delegate: self, cancelButtonTitle: "取消", otherButtonTitles: "重新登录")
// alertView.show()
}
}
Loading...
Report
Report success
We will send you the feedback within 2 working days through the letter!
Please fill in the reason for the report carefully. Provide as detailed a description as possible.
Please select a report type
Cancel
Send
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

About

O2OA是一款Java开源企业信息化建设平台,包括流程管理、门户管理、信息管理、数据管理和服务管理五大平台,可以大大减化企业信息化建设成本和业务应用开发难度。
Cancel

Releases

No release

Contributors

All

Activities

can not load any more
Edit
About
Homepage
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/java8dj/O2OA.git
git@gitee.com:java8dj/O2OA.git
java8dj
O2OA
O2OA
master
Going to Help Center

Search

Comment
Repository Report
Back to the top
Login prompt
This operation requires login to the code cloud account. Please log in before operating.
Go to login
No account. Register

AltStyle によって変換されたページ (->オリジナル) /