You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

90 lines
2.3 KiB

//
// AppDelegate.swift
// Lookfit
//
// Created by lemo. on 2020/3/1.
// Copyright © 2020 Sheldon. All rights reserved.
//
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate {
var window: UIWindow?
var httpdns: HttpDnsService?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let screen = UIScreen.main.bounds
window = UIWindow(frame: screen)
Application.shared.presentInitialScreen(in: window!)
JL_Tools.openLogTextFile()
// //
// Bluetooth.shareInstance()
// DNS
httpdns = HttpDnsService(accountID: 170287)
SystemAuthority.shared .getLocationAuthority{ [weak self] (result) in
if result{
}
}
return true
}
func applicationWillEnterForeground(_ application: UIApplication) {
self.stopKeepAlive()
if (UserDefaultsManager.getDeviceInfo() == nil)
{
return
}
if Bluetooth.shareInstance()!.isConnected {
NSLog("APP回到手表已连接")
}
else
{
NSLog("APP回到手表未连接")
//
Bluetooth.shareInstance()!.startAndStopReconnect(true)
// Bluetooth.shareInstance()?.connected(with: Bluetooth.shareInstance()?.currenModel)
}
}
var backTask :UIBackgroundTaskIdentifier?
//APP
func applicationDidEnterBackground(_ application: UIApplication) {
backTask = UIApplication.shared .beginBackgroundTask(expirationHandler: {
self.stopKeepAlive();
})
if Bluetooth.shareInstance()!.isConnected {
if Bluetooth.shareInstance()?.currenModel != nil{
NSLog("APP进入后台手表已连接")
if #available(iOS 13.0, *) {
} else {
// Fallback on earlier versions
}
}
}
}
//
func stopKeepAlive(){
if (backTask != nil){
UIApplication.shared.endBackgroundTask(backTask!)
backTask = .invalid
}
}
}
extension AppDelegate {
}