react-native-vconsole 0.0.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +39 -9
- package/Vconsole.podspec +25 -0
- package/android/build.gradle +61 -129
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +1 -2
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/vconsole/VconsoleModule.kt +80 -0
- package/android/src/main/java/com/vconsole/VconsolePackage.kt +17 -0
- package/ios/Vconsole.h +6 -0
- package/ios/Vconsole.mm +64 -0
- package/lib/module/VConsole.js +769 -0
- package/lib/module/VConsole.js.map +1 -0
- package/lib/module/core/consoleProxy.js +86 -0
- package/lib/module/core/consoleProxy.js.map +1 -0
- package/lib/module/core/xhrProxy.js +247 -0
- package/lib/module/core/xhrProxy.js.map +1 -0
- package/lib/module/index.js +24 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/VConsole.d.ts +6 -0
- package/lib/typescript/src/VConsole.d.ts.map +1 -0
- package/lib/typescript/src/core/consoleProxy.d.ts +9 -0
- package/lib/typescript/src/core/consoleProxy.d.ts.map +1 -0
- package/lib/typescript/src/core/xhrProxy.d.ts +12 -0
- package/lib/typescript/src/core/xhrProxy.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +9 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +37 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/package.json +138 -25
- package/src/VConsole.tsx +871 -0
- package/src/core/consoleProxy.ts +108 -0
- package/src/core/xhrProxy.ts +319 -0
- package/src/index.tsx +36 -0
- package/src/types.ts +42 -0
- package/android/README.md +0 -14
- package/android/src/main/java/wiki/qdc/rn/vconsole/ReactNativeVconsoleModule.java +0 -27
- package/android/src/main/java/wiki/qdc/rn/vconsole/ReactNativeVconsolePackage.java +0 -23
- package/index.js +0 -5
- package/ios/.DS_Store +0 -0
- package/ios/ReactNativeVconsole.h +0 -5
- package/ios/ReactNativeVconsole.m +0 -13
- package/ios/ReactNativeVconsole.xcodeproj/project.pbxproj +0 -281
- package/ios/ReactNativeVconsole.xcworkspace/contents.xcworkspacedata +0 -7
- package/react-native-vconsole.podspec +0 -28
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 davis
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,17 +1,47 @@
|
|
|
1
1
|
# react-native-vconsole
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
vconsole
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Installation
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
```sh
|
|
8
|
+
npm install react-native-vconsole
|
|
9
|
+
```
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
|
-
```javascript
|
|
13
|
-
import ReactNativeVconsole from 'react-native-vconsole';
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
import { VConsole } from 'react-native-vconsole';
|
|
16
|
+
|
|
17
|
+
export default function App() {
|
|
18
|
+
return (
|
|
19
|
+
<>
|
|
20
|
+
{/* your app content */}
|
|
21
|
+
<VConsole enable={true} filter={['localhost:8081']} />
|
|
22
|
+
</>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
17
25
|
```
|
|
26
|
+
|
|
27
|
+
## Features
|
|
28
|
+
|
|
29
|
+
- Draggable floating button (`vConsole`) with screen-boundary constraints.
|
|
30
|
+
- Bottom sheet panel (2/3 screen height) with `Log / Network / System / App` tabs.
|
|
31
|
+
- Log tab captures `console.log/info/warn/error` without breaking original console behavior.
|
|
32
|
+
- Network tab captures `XMLHttpRequest` requests/responses without breaking original request behavior.
|
|
33
|
+
- System/App tabs read info from native module bridges (`NativeModules.Vconsole`).
|
|
34
|
+
|
|
35
|
+

|
|
36
|
+
|
|
37
|
+
## Contributing
|
|
38
|
+
|
|
39
|
+
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
|
|
40
|
+
|
|
41
|
+
## License
|
|
42
|
+
|
|
43
|
+
MIT
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
|
package/Vconsole.podspec
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = "Vconsole"
|
|
7
|
+
s.version = package["version"]
|
|
8
|
+
s.summary = package["description"]
|
|
9
|
+
s.homepage = package["homepage"]
|
|
10
|
+
s.license = package["license"]
|
|
11
|
+
s.authors = package["author"]
|
|
12
|
+
|
|
13
|
+
s.platforms = { :ios => min_ios_version_supported }
|
|
14
|
+
s.source = { :git => "https://github.com/davistsin/react-native-vconsole.git", :tag => "#{s.version}" }
|
|
15
|
+
|
|
16
|
+
s.source_files = "ios/**/*.{h,m,mm}"
|
|
17
|
+
|
|
18
|
+
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
|
|
19
|
+
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
|
|
20
|
+
if respond_to?(:install_modules_dependencies, true)
|
|
21
|
+
install_modules_dependencies(s)
|
|
22
|
+
else
|
|
23
|
+
s.dependency "React-Core"
|
|
24
|
+
end
|
|
25
|
+
end
|
package/android/build.gradle
CHANGED
|
@@ -1,149 +1,81 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def DEFAULT_TARGET_SDK_VERSION = 28
|
|
17
|
-
|
|
18
|
-
def safeExtGet(prop, fallback) {
|
|
19
|
-
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
1
|
+
buildscript {
|
|
2
|
+
ext.getExtOrDefault = {name ->
|
|
3
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['Vconsole_' + name]
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
repositories {
|
|
7
|
+
google()
|
|
8
|
+
mavenCentral()
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
dependencies {
|
|
12
|
+
classpath "com.android.tools.build:gradle:8.7.2"
|
|
13
|
+
// noinspection DifferentKotlinGradleVersion
|
|
14
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
|
|
15
|
+
}
|
|
20
16
|
}
|
|
21
17
|
|
|
22
|
-
apply plugin: 'com.android.library'
|
|
23
|
-
apply plugin: 'maven'
|
|
24
18
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
// This avoids unnecessary downloads and potential conflicts when the library is included as a
|
|
28
|
-
// module dependency in an application project.
|
|
29
|
-
// ref: https://docs.gradle.org/current/userguide/tutorial_using_tasks.html#sec:build_script_external_dependencies
|
|
30
|
-
if (project == rootProject) {
|
|
31
|
-
repositories {
|
|
32
|
-
google()
|
|
33
|
-
jcenter()
|
|
34
|
-
}
|
|
35
|
-
dependencies {
|
|
36
|
-
classpath 'com.android.tools.build:gradle:3.4.1'
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
19
|
+
apply plugin: "com.android.library"
|
|
20
|
+
apply plugin: "kotlin-android"
|
|
40
21
|
|
|
41
|
-
apply plugin: 'com.android.library'
|
|
42
|
-
apply plugin: 'maven'
|
|
43
22
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
|
|
47
|
-
defaultConfig {
|
|
48
|
-
minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION)
|
|
49
|
-
targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
|
|
50
|
-
versionCode 1
|
|
51
|
-
versionName "1.0"
|
|
52
|
-
}
|
|
53
|
-
lintOptions {
|
|
54
|
-
abortOnError false
|
|
55
|
-
}
|
|
23
|
+
def getExtOrIntegerDefault(name) {
|
|
24
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["Vconsole_" + name]).toInteger()
|
|
56
25
|
}
|
|
57
26
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
|
|
63
|
-
url "$rootDir/../node_modules/react-native/android"
|
|
64
|
-
}
|
|
65
|
-
maven {
|
|
66
|
-
// Android JSC is installed from npm
|
|
67
|
-
url "$rootDir/../node_modules/jsc-android/dist"
|
|
68
|
-
}
|
|
69
|
-
google()
|
|
70
|
-
jcenter()
|
|
71
|
-
}
|
|
27
|
+
def supportsNamespace() {
|
|
28
|
+
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
|
|
29
|
+
def major = parsed[0].toInteger()
|
|
30
|
+
def minor = parsed[1].toInteger()
|
|
72
31
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
implementation 'com.facebook.react:react-native:+' // From node_modules
|
|
32
|
+
// Namespace support was added in 7.3.0
|
|
33
|
+
return (major == 7 && minor >= 3) || major >= 8
|
|
76
34
|
}
|
|
77
35
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
pom.project {
|
|
82
|
-
name packageJson.title
|
|
83
|
-
artifactId packageJson.name
|
|
84
|
-
version = packageJson.version
|
|
85
|
-
group = "wiki.qdc.rn.vconsole"
|
|
86
|
-
description packageJson.description
|
|
87
|
-
url packageJson.repository.baseUrl
|
|
88
|
-
|
|
89
|
-
licenses {
|
|
90
|
-
license {
|
|
91
|
-
name packageJson.license
|
|
92
|
-
url packageJson.repository.baseUrl + '/blob/master/' + packageJson.licenseFilename
|
|
93
|
-
distribution 'repo'
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
developers {
|
|
98
|
-
developer {
|
|
99
|
-
id packageJson.author.username
|
|
100
|
-
name packageJson.author.name
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
36
|
+
android {
|
|
37
|
+
if (supportsNamespace()) {
|
|
38
|
+
namespace "com.vconsole"
|
|
105
39
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
source = android.sourceSets.main.java.srcDirs
|
|
111
|
-
classpath += files(android.bootClasspath)
|
|
112
|
-
classpath += files(project.getConfigurations().getByName('compile').asList())
|
|
113
|
-
include '**/*.java'
|
|
40
|
+
sourceSets {
|
|
41
|
+
main {
|
|
42
|
+
manifest.srcFile "src/main/AndroidManifestNew.xml"
|
|
43
|
+
}
|
|
114
44
|
}
|
|
45
|
+
}
|
|
115
46
|
|
|
116
|
-
|
|
117
|
-
classifier = 'javadoc'
|
|
118
|
-
from androidJavadoc.destinationDir
|
|
119
|
-
}
|
|
47
|
+
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
120
48
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
49
|
+
defaultConfig {
|
|
50
|
+
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
51
|
+
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
buildTypes {
|
|
55
|
+
release {
|
|
56
|
+
minifyEnabled false
|
|
125
57
|
}
|
|
58
|
+
}
|
|
126
59
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
60
|
+
lintOptions {
|
|
61
|
+
disable "GradleCompatible"
|
|
62
|
+
}
|
|
130
63
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
64
|
+
compileOptions {
|
|
65
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
66
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
67
|
+
}
|
|
68
|
+
}
|
|
135
69
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
70
|
+
repositories {
|
|
71
|
+
mavenCentral()
|
|
72
|
+
google()
|
|
73
|
+
}
|
|
140
74
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
configureReactNativePom pom
|
|
147
|
-
}
|
|
148
|
-
}
|
|
75
|
+
def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
76
|
+
|
|
77
|
+
dependencies {
|
|
78
|
+
implementation "com.facebook.react:react-android"
|
|
79
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
149
80
|
}
|
|
81
|
+
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
package com.vconsole
|
|
2
|
+
|
|
3
|
+
import android.app.ActivityManager
|
|
4
|
+
import android.content.Context
|
|
5
|
+
import android.net.ConnectivityManager
|
|
6
|
+
import android.net.NetworkCapabilities
|
|
7
|
+
import android.os.Build
|
|
8
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
9
|
+
import com.facebook.react.bridge.Arguments
|
|
10
|
+
import com.facebook.react.bridge.Promise
|
|
11
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
12
|
+
import com.facebook.react.bridge.ReactMethod
|
|
13
|
+
|
|
14
|
+
class VconsoleModule(reactContext: ReactApplicationContext) :
|
|
15
|
+
ReactContextBaseJavaModule(reactContext) {
|
|
16
|
+
|
|
17
|
+
override fun getName(): String {
|
|
18
|
+
return NAME
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Example method
|
|
22
|
+
// See https://reactnative.dev/docs/native-modules-android
|
|
23
|
+
@ReactMethod
|
|
24
|
+
fun multiply(a: Double, b: Double, promise: Promise) {
|
|
25
|
+
promise.resolve(a * b)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@ReactMethod
|
|
29
|
+
fun getSystemInfo(promise: Promise) {
|
|
30
|
+
try {
|
|
31
|
+
val activityManager =
|
|
32
|
+
reactApplicationContext.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
|
|
33
|
+
val memoryInfo = ActivityManager.MemoryInfo()
|
|
34
|
+
activityManager.getMemoryInfo(memoryInfo)
|
|
35
|
+
|
|
36
|
+
val connectivityManager =
|
|
37
|
+
reactApplicationContext.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
|
38
|
+
val network = connectivityManager.activeNetwork
|
|
39
|
+
val capabilities = connectivityManager.getNetworkCapabilities(network)
|
|
40
|
+
|
|
41
|
+
val networkType = when {
|
|
42
|
+
capabilities == null -> "none"
|
|
43
|
+
capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) -> "wifi"
|
|
44
|
+
capabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) -> "cellular"
|
|
45
|
+
capabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET) -> "ethernet"
|
|
46
|
+
else -> "unknown"
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
val map = Arguments.createMap()
|
|
50
|
+
map.putString("manufacturer", Build.MANUFACTURER ?: "")
|
|
51
|
+
map.putString("model", Build.MODEL ?: "")
|
|
52
|
+
map.putString("osVersion", Build.VERSION.RELEASE ?: "")
|
|
53
|
+
map.putString("networkType", networkType)
|
|
54
|
+
map.putBoolean("isNetworkReachable", capabilities != null)
|
|
55
|
+
map.putDouble("totalMemory", memoryInfo.totalMem.toDouble())
|
|
56
|
+
map.putDouble("availableMemory", memoryInfo.availMem.toDouble())
|
|
57
|
+
promise.resolve(map)
|
|
58
|
+
} catch (error: Exception) {
|
|
59
|
+
promise.reject("SYSTEM_INFO_ERROR", error)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@ReactMethod
|
|
64
|
+
fun getAppInfo(promise: Promise) {
|
|
65
|
+
try {
|
|
66
|
+
val packageInfo =
|
|
67
|
+
reactApplicationContext.packageManager.getPackageInfo(reactApplicationContext.packageName, 0)
|
|
68
|
+
val map = Arguments.createMap()
|
|
69
|
+
map.putString("appVersion", packageInfo.versionName ?: "")
|
|
70
|
+
map.putString("buildNumber", packageInfo.longVersionCode.toString())
|
|
71
|
+
promise.resolve(map)
|
|
72
|
+
} catch (error: Exception) {
|
|
73
|
+
promise.reject("APP_INFO_ERROR", error)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
companion object {
|
|
78
|
+
const val NAME = "Vconsole"
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
package com.vconsole
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.ReactPackage
|
|
4
|
+
import com.facebook.react.bridge.NativeModule
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.uimanager.ViewManager
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class VconsolePackage : ReactPackage {
|
|
10
|
+
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
|
11
|
+
return listOf(VconsoleModule(reactContext))
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
15
|
+
return emptyList()
|
|
16
|
+
}
|
|
17
|
+
}
|
package/ios/Vconsole.h
ADDED
package/ios/Vconsole.mm
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#import "Vconsole.h"
|
|
2
|
+
#import <UIKit/UIKit.h>
|
|
3
|
+
|
|
4
|
+
@implementation Vconsole
|
|
5
|
+
RCT_EXPORT_MODULE()
|
|
6
|
+
|
|
7
|
+
// Example method
|
|
8
|
+
// See // https://reactnative.dev/docs/native-modules-ios
|
|
9
|
+
RCT_EXPORT_METHOD(multiply:(double)a
|
|
10
|
+
b:(double)b
|
|
11
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
12
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
13
|
+
{
|
|
14
|
+
NSNumber *result = @(a * b);
|
|
15
|
+
|
|
16
|
+
resolve(result);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
RCT_EXPORT_METHOD(getSystemInfo:(RCTPromiseResolveBlock)resolve
|
|
20
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
21
|
+
{
|
|
22
|
+
@try {
|
|
23
|
+
UIDevice *device = [UIDevice currentDevice];
|
|
24
|
+
NSProcessInfo *processInfo = [NSProcessInfo processInfo];
|
|
25
|
+
double totalMemory = (double)processInfo.physicalMemory;
|
|
26
|
+
|
|
27
|
+
NSDictionary *payload = @{
|
|
28
|
+
@"manufacturer": @"Apple",
|
|
29
|
+
@"model": device.model ?: @"",
|
|
30
|
+
@"osVersion": device.systemVersion ?: @"",
|
|
31
|
+
@"networkType": @"unknown",
|
|
32
|
+
@"isNetworkReachable": @(NO),
|
|
33
|
+
@"totalMemory": @(totalMemory),
|
|
34
|
+
@"availableMemory": @(0)
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
resolve(payload);
|
|
38
|
+
} @catch (NSException *exception) {
|
|
39
|
+
reject(@"SYSTEM_INFO_ERROR", exception.reason, nil);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
RCT_EXPORT_METHOD(getAppInfo:(RCTPromiseResolveBlock)resolve
|
|
44
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
45
|
+
{
|
|
46
|
+
@try {
|
|
47
|
+
NSDictionary *infoDictionary =
|
|
48
|
+
[[NSBundle mainBundle] infoDictionary];
|
|
49
|
+
NSString *version =
|
|
50
|
+
[infoDictionary objectForKey:@"CFBundleShortVersionString"] ?: @"";
|
|
51
|
+
NSString *buildNumber =
|
|
52
|
+
[infoDictionary objectForKey:@"CFBundleVersion"] ?: @"";
|
|
53
|
+
|
|
54
|
+
NSDictionary *payload = @{
|
|
55
|
+
@"appVersion": version,
|
|
56
|
+
@"buildNumber": buildNumber
|
|
57
|
+
};
|
|
58
|
+
resolve(payload);
|
|
59
|
+
} @catch (NSException *exception) {
|
|
60
|
+
reject(@"APP_INFO_ERROR", exception.reason, nil);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@end
|