Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(device): Improving iOSVersion consistency #1514

Merged
merged 4 commits into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions device/ios/Plugin/Device.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,30 @@ import UIKit
}

public func getSystemVersionInt() -> Int? {
let majorVersion = UIDevice.current.systemVersion.split(separator: ".")
let majorVersionBig = majorVersion.joined()
let majorVersionBigInt = Int(majorVersionBig)
let exploded = UIDevice.current.systemVersion.split(separator: ".")

return majorVersionBigInt
var major = 0
var minor = 0
var patch = 0

for (index, numStr) in exploded.enumerated() {
switch index {
case 0:
major = Int(numStr) ?? 0
case 1:
minor = Int(numStr) ?? 0
case 2:
patch = Int(numStr) ?? 0
default:
break
}
}

var combined: [String] = []
combined.append(String(format: "%02d", major))
combined.append(String(format: "%02d", minor))
combined.append(String(format: "%02d", patch))

return Int(combined.joined())
}
}
2 changes: 1 addition & 1 deletion device/src/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export interface DeviceInfo {
*
* Only available on iOS.
*
* Multi-part version numbers are crushed down into an integer, ex: `"16.3.1"` -> `1631`
* Multi-part version numbers are crushed down into an integer padded to two-digits, ex: `"16.3.1"` -> `160301`
*
* @since 5.0.0
*/
Expand Down