Skip to content

Commit

Permalink
Fix crash in connectivity sensor on iOS 14.0 (and not 14.1+) (#1238)
Browse files Browse the repository at this point in the history
The 5G connectivity defines are declared available in iOS 14.0+ but evaluate to nil or whatever on iOS 14.0.
  • Loading branch information
zacwest committed Oct 25, 2020
1 parent 6f13c90 commit 8427d32
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Sources/Shared/API/Webhook/Sensors/ConnectivitySensor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ public class ConnectivitySensor: SensorProvider {
case CTRadioAccessTechnologyLTE:
return "Long-Term Evolution (LTE)"
default:
if #available(iOS 14, *) {
if #available(iOS 14.1, *) {
// although these are declared available in 14.0, they will crash on use before 14.1
switch radioTech {
case CTRadioAccessTechnologyNR:
return "5G"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ public enum NetworkType: Int, CaseIterable {

#if !targetEnvironment(macCatalyst)
init(_ radioTech: String) {
if #available(iOS 14, *), [CTRadioAccessTechnologyNR, CTRadioAccessTechnologyNRNSA].contains(radioTech) {
if #available(iOS 14.1, *), [CTRadioAccessTechnologyNR, CTRadioAccessTechnologyNRNSA].contains(radioTech) {
// although these are declared available in 14.0, they will crash on use before 14.1
self = .wwan5g
return
}
Expand Down

0 comments on commit 8427d32

Please sign in to comment.