Skip to content

Commit

Permalink
Fix build on visionOS 1.1 (stripe#3304)
Browse files Browse the repository at this point in the history
## Summary
Fix the build on visionOS 1.1. Also change the output to "Wi-Fi", as we
can assume a device without CoreTelephony is on wifi.

## Motivation
SCNetworkReachabilityCreateWithName is no longer available on visionOS
1.1.

## Testing
Manually in Xcode 15.3 beta 3. Will add Xcode 15.3 to CI soon.

## Changelog
None
  • Loading branch information
davidme-stripe authored Feb 16, 2024
1 parent 2372395 commit a97afd7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions StripeCore/StripeCore/Source/Analytics/NetworkDetector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import SystemConfiguration
class NetworkDetector {

static func getConnectionType() -> String? {
#if canImport(CoreTelephony)
guard let reachability = SCNetworkReachabilityCreateWithName(kCFAllocatorDefault, "www.stripe.com") else {
return nil
}
Expand All @@ -32,7 +33,7 @@ class NetworkDetector {
guard isWWAN else {
return "Wi-Fi"
}
#if canImport(CoreTelephony)

let networkInfo = CTTelephonyNetworkInfo()
let carrierType = networkInfo.serviceCurrentRadioAccessTechnology

Expand All @@ -51,7 +52,7 @@ class NetworkDetector {
return "5G"
}
#else
return "unknown"
return "Wi-Fi"
#endif
}

Expand Down

0 comments on commit a97afd7

Please sign in to comment.