2024-08-05 21:21:34 +02:00
|
|
|
import ExpoModulesCore
|
|
|
|
|
|
|
|
public class ExpoPlatformInfoModule: Module {
|
|
|
|
public func definition() -> ModuleDefinition {
|
|
|
|
Name("ExpoPlatformInfo")
|
|
|
|
|
|
|
|
Function("getIsReducedMotionEnabled") {
|
|
|
|
return UIAccessibility.isReduceMotionEnabled
|
|
|
|
}
|
2024-08-09 12:05:12 +02:00
|
|
|
|
2024-08-09 23:35:26 +02:00
|
|
|
Function("setAudioCategory") { (audioCategoryString: String) in
|
|
|
|
let audioCategory = AVAudioSession.Category(rawValue: audioCategoryString)
|
2024-08-13 05:08:51 +02:00
|
|
|
|
|
|
|
DispatchQueue.global(qos: .background).async {
|
|
|
|
try? AVAudioSession.sharedInstance().setCategory(audioCategory)
|
|
|
|
}
|
2024-08-09 23:35:26 +02:00
|
|
|
}
|
|
|
|
|
2024-08-10 01:52:23 +02:00
|
|
|
Function("setAudioActive") { (active: Bool) in
|
|
|
|
if active {
|
2024-08-13 05:08:51 +02:00
|
|
|
DispatchQueue.global(qos: .background).async {
|
|
|
|
try? AVAudioSession.sharedInstance().setActive(true)
|
|
|
|
}
|
2024-08-09 12:05:12 +02:00
|
|
|
} else {
|
2024-08-13 05:08:51 +02:00
|
|
|
DispatchQueue.global(qos: .background).async {
|
|
|
|
try? AVAudioSession
|
|
|
|
.sharedInstance()
|
|
|
|
.setActive(
|
|
|
|
false,
|
|
|
|
options: [.notifyOthersOnDeactivation]
|
|
|
|
)
|
|
|
|
}
|
2024-08-09 12:05:12 +02:00
|
|
|
}
|
|
|
|
}
|
2024-08-05 21:21:34 +02:00
|
|
|
}
|
|
|
|
}
|