How can we check if the OS running on iPhone is the latest one. Is there any API for that?
Asked
Active
Viewed 827 times
1
-
You can find a quite big discussion here: https://stackoverflow.com/questions/24503001/check-os-version-in-swift#24505884 – Iskandir Jun 09 '21 at 08:46
-
1this is not the same question. have you even read the question. For example, user is using iOS 14.6, so I want to know if its the latest version that he is using – Habib Ali Jun 09 '21 at 09:42
-
AFAIK, there is not an API for this. You could use one of the techniques in the linked question to get the current iOS version, and check it against your own API. You would, of course, have to update your API with the latest/current version. – livingtech Jun 09 '21 at 15:05
1 Answers
1
An availability of the specific version iOS version can be checked with @available
:
if (@available(iOS 11, *)) {
// Use iOS 11 APIs.
} else {
// Alternative code for earlier versions of iOS.
}
More details: https://developer.apple.com/documentation/swift/objective-c_and_c_code_customization/marking_api_availability_in_objective-c
"The latest version" is a very relative concept, and you usually should use this macro to check if the specific frameworks/APIs are supported, no matter if their iOS version is the "latest".

olha
- 2,132
- 1
- 18
- 39
-
this is not the answer. For example, user is using iOS 14.6, so I want to know if its the latest version that he is using – Habib Ali Jun 09 '21 at 09:41