{"id":13902286,"url":"https://github.com/swapnil-musale/KDeviceInfo","last_synced_at":"2025-07-18T00:31:24.434Z","repository":{"id":219961391,"uuid":"748517210","full_name":"swapnil-musale/KDeviceInfo","owner":"swapnil-musale","description":"Multiplatform Library for accessing DeviceInfo","archived":false,"fork":false,"pushed_at":"2024-04-14T08:59:29.000Z","size":237,"stargazers_count":47,"open_issues_count":8,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-14T13:20:18.404Z","etag":null,"topics":["android","compose-multiplatform-library","device-info","ios","kdeviceinfo","kmp","kotlin-multiplatform"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/swapnil-musale.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":"CONTRIBUTING.MD","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-01-26T06:32:43.000Z","updated_at":"2024-04-17T20:33:56.034Z","dependencies_parsed_at":"2024-04-17T20:44:07.432Z","dependency_job_id":null,"html_url":"https://github.com/swapnil-musale/KDeviceInfo","commit_stats":null,"previous_names":["swapnil-musale/kdeviceinfo"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swapnil-musale%2FKDeviceInfo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swapnil-musale%2FKDeviceInfo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swapnil-musale%2FKDeviceInfo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swapnil-musale%2FKDeviceInfo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/swapnil-musale","download_url":"https://codeload.github.com/swapnil-musale/KDeviceInfo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":214260218,"owners_count":15707057,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","compose-multiplatform-library","device-info","ios","kdeviceinfo","kmp","kotlin-multiplatform"],"created_at":"2024-08-06T22:01:05.002Z","updated_at":"2025-07-18T00:31:24.422Z","avatar_url":"https://github.com/swapnil-musale.png","language":"Kotlin","funding_links":[],"categories":["Kotlin"],"sub_categories":[],"readme":"# KDeviceInfo\n\nA Kotlin Multiplatform library to easily access device, OS, and environment information across **Android**, **iOS**, **Desktop (JVM)**, and **Web (WASM)** — all with a single unified API.\n\n\u003cp  align=\"center\"\u003e\n\u003ca  href=\"https://github.com/swapnil-musale/KDeviceInfo\"\u003e\u003cimg  src=\"https://img.shields.io/badge/Platform-Android-Blue?style=for-the-badge\"  alt=\"Android\"/\u003e\u003c/a\u003e\u0026nbsp; \u003ca  href=\"https://github.com/swapnil-musale/KDeviceInfo\"\u003e\u003cimg  src=\"https://img.shields.io/badge/Platform-Ios-Blue?style=for-the-badge\"  alt=\"Ios\"/\u003e\u003c/a\u003e\u0026nbsp; \u003ca  href=\"https://github.com/swapnil-musale/KDeviceInfo\"\u003e\u003cimg  src=\"https://img.shields.io/badge/Platform-Desktop-Blue?style=for-the-badge\"  alt=\"Desktop\"/\u003e\u003c/a\u003e\u0026nbsp; \u003ca  href=\"https://github.com/swapnil-musale/KDeviceInfo\"\u003e\u003cimg  src=\"https://img.shields.io/badge/Platform-Web-Blue?style=for-the-badge\"  alt=\"Web\"/\u003e\u003c/a\u003e\u0026nbsp; \u003ca  href=\"https://search.maven.org/artifact/io.github.swapnil-musale/KDeviceInfo\"\u003e\u003cimg  src=\"https://img.shields.io/maven-central/v/io.github.swapnil-musale/KDeviceInfo?style=for-the-badge\"  alt=\"Maven Central\"/\u003e\u003c/a\u003e\u0026nbsp; \u003ca  href=\"https://github.com/swapnil-musale/KDeviceInfo/actions\"\u003e\u003cimg  src=\"https://img.shields.io/github/actions/workflow/status/swapnil-musale/KDeviceInfo/build.yml?style=for-the-badge\"  alt=\"CI Status\"/\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n---\n\n# 🚀 Features\n\n- 🌍 **Cross-Platform** — Android, iOS, Desktop (Windows, macOS, Linux), Web (WASM)\n- 💬 **Unified API** — Use `DeviceInfoXState` everywhere\n- ⚡ **Lightweight and Easy to Use**\n- 🎯 **Kotlin Multiplatform First-Class Support**\n\n---\n\n# 📦 Installation\n\nThis library is available on mavenCentral. To use it in your project add following block of code\nin ```settings.gradle.kts``` file if not available.\n\n```kotlin\nrepositories { \n    ...\n    mavenCentral()\n}\n```\n\n### 1. Kotlin Multiplatform\nAdd the library dependency in ```shared``` module (```build.gradle.kts```)\n\n```kotlin\ncommonMain.dependencies {\n    ...\n    api or implementation(\"io.github.swapnil-musale:KDeviceInfo:0.0.7\")\n}\n```\n\n### 2. Compose Multiplatform\n\nAdd the library dependency in ```composeApp``` module (```build.gradle.kts```)\n\n```kotlin\ncommonMain.dependencies {\n    ...\n    implementation(\"io.github.swapnil-musale:KDeviceInfo:0.0.7\")\n}\n```\n---\n\n# 🔥 Usage\n\nImplementation of **KDeviceInfo** is pretty straightforward. Simply import the **DeviceInfoXState**\nand start accessing device information in your Compose Multiplatform project.\n\n```kotlin\n@Composable\nfun DeviceInfoExample() {\n\n    val deviceInfoXState: DeviceInfoXState = rememberDeviceInfoXState()\n    \n    Column(modifier = Modifier.fillMaxSize()) {\n        if (deviceInfoXState.isAndroid) {\n            // Android\n            val androidInfo = deviceInfoXState.androidInfo\n            Text(text = \"App Name : ${androidInfo.appName}\")\n            Text(text = \"SdkInt : ${androidInfo.version.sdkInt}\")\n            Text(text = \"PackageName : ${androidInfo.packageName}\")\n        } else if(deviceInfoXState.isIos) {\n            // iOS\n            val iosInfo = deviceInfoXState.iosInfo\n            Text(text = \"SystemName : ${iosInfo.systemName}\")\n            Text(text = \"SystemVersion : ${iosInfo.systemVersion}\")\n            Text(text = \"IsPhysicalDevice : ${iosInfo.isPhysicalDevice}\")\n        } else if(deviceInfoXState.isDesktop) {\n            // Desktop\n            val desktopInfo = deviceInfoXState.desktopInfo\n            val operatingSystem = desktopInfo.operatingSystem\n            Text(text = \"Operating System Info\", style = TextStyle(fontSize = 20.sp))\n            Text(text = \"Family : ${operatingSystem.family}\")\n            Text(text = \"Manufacturer : ${operatingSystem.manufacturer}\")\n        } else if(deviceInfoXState.isWeb) {\n            // Web\n            val webInfo = deviceInfoXState.webInfo\n            val browser = webInfo.browser\n            Text(text = \"Browser Info\", style = TextStyle(fontSize = 20.sp))\n            Text(text = \"Name : ${browser.name}\")\n            Text(text = \"Version : ${browser.version}\")\n        }\n    }\n}\n```\n\n**OR** Use helper function to access device information\n\n```kotlin\n@Composable\nfun DeviceInfoExample() {\n    Column(modifier = Modifier.fillMaxSize()) {\n        OnPlatform(\n            onAndroid = { androidInfo -\u003e\n                Text(text = \"App Name : ${androidInfo.appName}\")\n                Text(text = \"SdkInt : ${androidInfo.version.sdkInt}\")\n                Text(text = \"PackageName : ${androidInfo.packageName}\")\n            },\n            onIos = { iosInfo -\u003e\n                Text(text = \"SystemName : ${iosInfo.systemName}\")\n                Text(text = \"SystemVersion : ${iosInfo.systemVersion}\")\n                Text(text = \"IsPhysicalDevice : ${iosInfo.isPhysicalDevice}\")\n            },\n            onDesktop = { desktopInfo -\u003e\n                Text(text = \"SystemName : ${desktopInfo.operatingSystem.versionInfo.version}\")\n            },\n            onWeb = { webInfo -\u003e\n                Text(text = \"SystemName : ${webInfo.os.version}\")\n            }\n        )\n    }\n}\n```\n\nTo access the device details outside the Composable function you can make use of **DeviceInfoState** as below\n\n```kotlin\nclass AppViewModel {\n\n    private val deviceInfoXState: DeviceInfoXState = DeviceInfoXState()\n\n    init {\n        if (deviceInfoXState.isAndroid) {\n            val androidInfo: AndroidInfo = deviceInfoXState.androidInfo\n            println(\"DeviceInfoX - App Name : ${androidInfo.appName}\")\n        } else if (deviceInfoXState.isIos) {\n            val iosInfo: IosInfo = deviceInfoXState.iosInfo\n            println(\"DeviceInfoX - System Name : ${iosInfo.systemName}\")\n        } else if (deviceInfoXState.isDesktop) {\n            val desktopInfo = deviceInfoXState.desktopInfo\n            println(\"DeviceInfoX - System Name : ${desktopInfo.operatingSystem.versionInfo.version}\")\n        } else if (deviceInfoXState.isWeb) {\n            val webInfo = deviceInfoXState.webInfo\n            println(\"DeviceInfoX - System Name : ${webInfo.os.version}\")\n        }\n    }\n}\n```\n\n**OR** Use helper function to access device information\n\n```kotlin\nclass AppViewModel {\n    init {\n        onPlatform(\n            onAndroid = { androidInfo -\u003e\n                println(\"DeviceInfoX - App Name : ${androidInfo.appName}\")\n            },\n            onIos = { iosInfo -\u003e\n                println(\"DeviceInfoX - System Name : ${iosInfo.systemName}\")\n            },\n            onDesktop = { desktopInfo -\u003e\n                println(\"DeviceInfoX - System Name : ${desktopInfo.operatingSystem.versionInfo.version}\")\n            },\n            onWeb = { webInfo -\u003e\n                println(\"DeviceInfoX - System Name : ${webInfo.os.version}\")\n            }\n        )\n    }\n}\n```\n\nYou can access more info using this **State** API, for more information about API usage in your\nCompose Multiplatform project check out [Sample App Example][9].\n\n\n# 📚 API Reference\n\nYou can explore full platform-specific models like:\n\n- [`AndroidInfo`][5]\n- [`IosInfo`][6]\n- [`DesktopInfo`][7]\n- [`WebInfo`][8]\n\n---\n\n# 🤝 Contributions\n\nContributions to KDeviceInfo are super welcome checkout [Contributions Guidelines][4]. If you encounter any issues or have suggestions for\nimprovements, please feel free to open an issue or submit a pull request on GitHub.\n\n---\n\n## 🔗 Connect with me\n\n[![Github Profile](https://skillicons.dev/icons?i=github)][1]\n[![LinkedIn](https://skillicons.dev/icons?i=linkedin)][2]\n[![Twitter](https://skillicons.dev/icons?i=twitter)][3]\n\n---\n\n[0]: https://github.com/swapnil-musale/KDeviceInfo/blob/master/sampleApp/composeApp/src/commonMain/kotlin/com/devx/kdeviceinfo/sample/App.kt\n[1]: https://github.com/swapnil-musale\n[2]: https://linkedin.com/in/swapnil-musale\n[3]: https://twitter.com/swapnil_musale\n[4]: https://github.com/swapnil-musale/KDeviceInfo/blob/master/CONTRIBUTING.MD\n[5]: https://github.com/swapnil-musale/KDeviceInfo/blob/master/KDeviceInfo/src/commonMain/kotlin/com/devx/kdeviceinfo/model/android/AndroidInfo.kt\n[6]: https://github.com/swapnil-musale/KDeviceInfo/blob/master/KDeviceInfo/src/commonMain/kotlin/com/devx/kdeviceinfo/model/ios/IosInfo.kt\n[7]: https://github.com/swapnil-musale/KDeviceInfo/blob/master/KDeviceInfo/src/commonMain/kotlin/com/devx/kdeviceinfo/model/desktop/DesktopInfo.kt\n[8]: https://github.com/swapnil-musale/KDeviceInfo/blob/master/KDeviceInfo/src/commonMain/kotlin/com/devx/kdeviceinfo/model/web/WebInfo.kt\n[9]: https://github.com/swapnil-musale/KDeviceInfo/blob/master/sampleApp/composeApp/src/commonMain/kotlin/com/devx/kdeviceinfo/sample/App.kt\n# Licence\n\n```\nMIT License\n\nCopyright (c) 2024 Swapnil Musale\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswapnil-musale%2FKDeviceInfo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswapnil-musale%2FKDeviceInfo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswapnil-musale%2FKDeviceInfo/lists"}