mirror of
https://github.com/wanghongenpin/proxypin.git
synced 2026-05-20 16:15:47 +08:00
请求重写支持选择文件
This commit is contained in:
@@ -34,17 +34,31 @@ import NetworkExtension
|
||||
|
||||
|
||||
override func applicationDidEnterBackground(_ application: UIApplication) {
|
||||
// timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(timerAction), userInfo: nil, repeats: true)
|
||||
// RunLoop.current.add(timer!, forMode: RunLoop.Mode.common)
|
||||
// bgTask = application.beginBackgroundTask(expirationHandler: nil)
|
||||
if (!VpnManager.shared.isRunning()) {
|
||||
return
|
||||
}
|
||||
timer = Timer.scheduledTimer(timeInterval: 3, target: self, selector: #selector(timerAction), userInfo: nil, repeats: true)
|
||||
RunLoop.current.add(timer!, forMode: RunLoop.Mode.common)
|
||||
bgTask = application.beginBackgroundTask(expirationHandler: nil)
|
||||
}
|
||||
|
||||
@objc func timerAction() {
|
||||
print(UIApplication.shared.backgroundTimeRemaining )
|
||||
if UIApplication.shared.backgroundTimeRemaining < 60.0 {
|
||||
let application = UIApplication.shared
|
||||
bgTask = application.beginBackgroundTask(expirationHandler: nil)
|
||||
}
|
||||
print(UIApplication.shared.backgroundTimeRemaining)
|
||||
let application = UIApplication.shared
|
||||
if (bgTask != nil) {
|
||||
application.endBackgroundTask(bgTask!);
|
||||
bgTask = nil;
|
||||
}
|
||||
|
||||
if (UIApplication.shared.backgroundTimeRemaining < 60 && VpnManager.shared.isRunning()) {
|
||||
bgTask = application.beginBackgroundTask(expirationHandler: nil)
|
||||
}
|
||||
|
||||
if (application.backgroundTimeRemaining <= 0 || application.applicationState == .active) {
|
||||
timer?.invalidate();
|
||||
timer = nil;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override func applicationWillResignActive(_ application: UIApplication) {
|
||||
|
||||
@@ -2,6 +2,11 @@
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleLocalizations</key>
|
||||
<array>
|
||||
<string>en</string>
|
||||
<string>zh</string>
|
||||
</array>
|
||||
<key>BGTaskSchedulerPermittedIdentifiers</key>
|
||||
<array>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
@@ -62,6 +67,6 @@
|
||||
<key>UIViewControllerBasedStatusBarAppearance</key>
|
||||
<false/>
|
||||
<key>NSCameraUsageDescription</key>
|
||||
<string>扫描二维码</string>
|
||||
<string>扫描二维码</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
@@ -164,9 +164,7 @@ extension VpnManager{
|
||||
}
|
||||
|
||||
loadProviderManager{
|
||||
print("stopVPNTunnel")
|
||||
$0?.connection.stopVPNTunnel()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user