mirror of
https://github.com/CopterExpress/clover.git
synced 2026-05-26 11:43:25 +00:00
Somes fixes to iOS app
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>2</string>
|
||||
<string>3</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
|
||||
@@ -10,12 +10,13 @@ import UIKit
|
||||
import WebKit
|
||||
import SwiftSocket
|
||||
import NotificationBannerSwift
|
||||
import AudioToolbox.AudioServices
|
||||
|
||||
class ViewController: UIViewController, WKScriptMessageHandler {
|
||||
@IBOutlet weak var webView: WKWebView!
|
||||
let impactGenerator = UIImpactFeedbackGenerator(style: .medium)
|
||||
let notificationGenerator = UINotificationFeedbackGenerator()
|
||||
let udpSocket = UDPClient(address:"255.255.255.255", port: 35602)
|
||||
let udpSocket = UDPClient(address: "255.255.255.255", port: 35602)
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
@@ -57,7 +58,7 @@ class ViewController: UIViewController, WKScriptMessageHandler {
|
||||
} else if (message.name == "lowBattery") {
|
||||
// Got low battery notification
|
||||
print("Low battery notification")
|
||||
notificationGenerator.notificationOccurred(.warning)
|
||||
tapticNotify()
|
||||
} else if (message.name == "notification") {
|
||||
// Got notification message
|
||||
print(message)
|
||||
@@ -72,4 +73,22 @@ class ViewController: UIViewController, WKScriptMessageHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func tapticNotify() {
|
||||
if let feedbackSupportLevel = UIDevice.current.value(forKey: "_feedbackSupportLevel") as? Int {
|
||||
switch feedbackSupportLevel {
|
||||
case 2:
|
||||
// 2nd Generation Taptic Engine w/ Haptic Feedback (iPhone 7/7+)
|
||||
notificationGenerator.notificationOccurred(.warning)
|
||||
case 1:
|
||||
// 1st Generation Taptic Engine (iPhone 6S/6S+)
|
||||
let peek = SystemSoundID(1519)
|
||||
AudioServicesPlaySystemSound(peek)
|
||||
case 0:
|
||||
// No Taptic Engine
|
||||
break
|
||||
default: break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user