Skip to content

Add support for checking if the iOS app is running on macOS #10

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
12 changes: 10 additions & 2 deletions ios/RNAptabaseModule.swift
Original file line number Diff line number Diff line change
@@ -2,12 +2,20 @@ import Foundation

@objc(RNAptabaseModule)
class RNAptabaseModule: NSObject {

@objc
func constantsToExport() -> [AnyHashable : Any]! {
return [
"appVersion": Bundle.main.infoDictionary?["CFBundleShortVersionString"] as Any,
"appBuildNumber": Bundle.main.infoDictionary?["CFBundleVersion"] as Any
]
"appBuildNumber": Bundle.main.infoDictionary?["CFBundleVersion"] as Any,
"isiOSAppOnMac": {
if #available(iOS 14.0, *) {
return ProcessInfo.processInfo.isiOSAppOnMac
} else {
return false
}
}()
]
}

@objc
4 changes: 4 additions & 0 deletions src/env.ts
Original file line number Diff line number Diff line change
@@ -36,6 +36,10 @@ function getOperatingSystem(): [string, string] {
return ["Android", Platform.constants.Release];
case "ios":
if (Platform.isPad) {
if (version.isiOSAppOnMac) {
// Version represents the emulated iPadOS version and not the MacOS version
return ["MacOS", Platform.Version];
}
return ["iPadOS", Platform.Version];
}
return ["iOS", Platform.Version];
2 changes: 2 additions & 0 deletions src/version.ts
Original file line number Diff line number Diff line change
@@ -5,11 +5,13 @@ const { RNAptabaseModule } = NativeModules;
type VersionObject = {
appVersion: string;
appBuildNumber: string;
isiOSAppOnMac: boolean;
};

const Version: VersionObject = {
appVersion: RNAptabaseModule?.appVersion?.toString() ?? "",
appBuildNumber: RNAptabaseModule?.appBuildNumber?.toString() ?? "",
isiOSAppOnMac: RNAptabaseModule?.isiOSAppOnMac ?? false,
};

export default Version;