mirror of
https://github.com/kiwix/kiwix-apple.git
synced 2025-09-28 14:35:03 -04:00
Cellular capability detection
This commit is contained in:
parent
d43c964e3d
commit
14bbbd29bf
@ -60,3 +60,19 @@ extension Bundle {
|
||||
return (Bundle.main.object(forInfoDictionaryKey: kCFBundleVersionKey as String) as? String) ?? "Unknown"
|
||||
}
|
||||
}
|
||||
|
||||
extension UIDevice {
|
||||
class var hasCellularCapability: Bool {
|
||||
// Get list of all interfaces on the local machine:
|
||||
var ifaddr : UnsafeMutablePointer<ifaddrs>? = nil
|
||||
if getifaddrs(&ifaddr) == 0 {
|
||||
var ptr = ifaddr
|
||||
while ptr != nil {
|
||||
ptr = ptr!.pointee.ifa_next
|
||||
let ifaName = String(utf8String: ptr!.pointee.ifa_name)
|
||||
if ifaName == "pdp_ip0" {return true}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
@ -5,3 +5,4 @@
|
||||
#import "ZimReader.h"
|
||||
#import "ZimIndexer.h"
|
||||
|
||||
#include <ifaddrs.h>
|
||||
|
@ -133,7 +133,7 @@ extension AlertProcedure {
|
||||
if book.state == .cloud {
|
||||
alert.add(actionWithTitle: Localized.Library.download, style: .default) { _ in
|
||||
OperationQueue.main.addOperation({
|
||||
if true {
|
||||
if UIDevice.hasCellularCapability {
|
||||
UIQueue.shared.add(operation: download(context: context, bookID: book.id))
|
||||
} else {
|
||||
Network.shared.start(bookID: book.id, useWifiAndCellular: false)
|
||||
|
Loading…
x
Reference in New Issue
Block a user