Skip to content

Commit

Permalink
fix(device): Improving iOSVersion consistency (#1514)
Browse files Browse the repository at this point in the history
  • Loading branch information
theproducer committed Mar 31, 2023
1 parent d5d4584 commit b697fee
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
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

0 comments on commit b697fee

Please sign in to comment.