3

Apple will release the iPhone12 in this year, and the iPhone12(some higher device type) can support the 5G feature, I think the iPhone12 should be based on iOS14 platform, so I looked into the iOS14 APIs, but we can't find any new APIs about the 5G. Does anybody know the some information about 5G detection of the iPhone12?

Appreciated for the information from anybody!

iOS14 API diff: https://developer.apple.com/documentation/technologies?changes=latest_major

Chos
  • 111
  • 1
  • 7

1 Answers1

9

Probably you should be looking into CTTelephonyNetworkInfo, where you'll find serviceCurrentRadioAccessTechnology, as well as currentRadioAccessTechnology. That should offer you what you want.

However, I wouldn't be able to tell you what the key or value for 5G will be. Given they're all Strings though, a new one could just show up and probably a future version of Xcode 12 would add a property to strong type it.

For reference, this SO answer shows how to identify 2G, 3G and 4G.

Later update: Core Telephony Constants has shown up and provides 2 new strings, CTRadioAccessTechnologyNR and CTRadioAccessTechnologyNRNSA, both available from iOS 14+ (reasonable given iPhone 12s are first with the tech). This should be reinforced by the term NR, which seems to be part of 5Gs naming 5G NR (New Radio). I don't have a phone to test today, so still yet to confirm where this property will show up, but I'd still guess within CTTelephonyNetworkInfo().serviceCurrentRadioAccessTechnology.

For reference, to test this, you need to import CoreTelephony.

Latest update:

Big thanks to Alessandro Martin for sharing this in the comment:

There's a mistake on Apple's part as the CTRadioAccessTechnologyNR and CTRadioAccessTechnologyNRSA strings are marked as available from iOS 14.0 but in fact it should be iOS 14.1 Take into account that a user on iOS 14.2 beta will pass the availability check but it will crash with a null pointer exception when trying to access these strings as they are not available to them.

Alex Ioja-Yang
  • 1,428
  • 13
  • 28
  • Thank you very much, This does make sense. – Chos Nov 14 '20 at 05:51
  • Important! iOS version >= iOS 14.1 – michaelxing Dec 21 '20 at 08:21
  • Hi @michaelxing, I am not sure what requires iOS 14.1 + ? `CTTelephonyNetworkInfo.serviceCurrentRadioAccessTechnology` is 12 +. `CTRadioAccessTechnologyNR` and `CTRadioAccessTechnologyNRNSA` are 14.0+. Strictly based on API `@available` flags, nothing in the answer requires 14.1 – Alex Ioja-Yang Dec 21 '20 at 10:56
  • A bit late to the party... But: it's somehow confusing. While the docs say "14.0+", this link says "14.2+" https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&ved=2ahUKEwi4q_WSxILuAhWCuaQKHS6PD2cQFjADegQIAhAC&url=http%3A%2F%2Fcodeworkshop.net%2Fobjc-diff%2Fsdkdiffs%2Fios%2F14.2%2FCoreTelephony.html&usg=AOvVaw1_8nEDieShlRNp1hvAeVuo Which is also what my compiler tells me. – Kai Huppmann Jan 04 '21 at 15:07
  • 3
    There's a mistake on Apple's part as the `CTRadioAccessTechnologyNR` and `CTRadioAccessTechnologyNRSA` strings are marked as available from iOS 14.0 but in fact it should be iOS 14.1 Take into account that a user on iOS 14.2 beta will pass the availability check but it will crash with a null pointer exception when trying to access these strings as they are not available to them. – Alessandro Martin Jan 13 '21 at 12:07
  • 2
    @AlexIoja-Yang apple document is wrong. "CTRadioAccessTechnologyNR and CTRadioAccessTechnologyNRNSA are 14.0+." need 14.1 – michaelxing Jan 21 '21 at 08:52
  • @AlessandroMartin Can you explain why iOS 14.2 beta users would still not have these strings if they are available in iOS 14.1? – Mihai Damian Feb 10 '21 at 14:17
  • @MihaiDamian Because iOS 14.2 entered beta before 14.1 was released, so the first couple of 14.2 betas don't have the 14.1 additions yet since Apple rebased later on. If you do and availability check for iOS 14.1 in 14.2 it will pass but you will be trying to dereference a null pointer when accessing the 5G constants. – Alessandro Martin Feb 11 '21 at 17:16
  • I found that the CTRadioAccessTechnologyNR, CTRadioAccessTechnologyNRNSA is available after 14.0+, a old device below iPhone 12 with iOS 14.0+ system sometimes will crash here. – childrenOurFuture Jun 10 '21 at 07:18
  • 1
    it now actually has @available(iOS 14.1, *) – Zaporozhchenko Oleksandr Oct 08 '21 at 04:29