react-native-ble-manager 11.5.7 → 12.0.0-rc.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/README.md +16 -3
- package/RNBleManager.podspec +24 -0
- package/android/build.gradle +116 -43
- package/android/gradle.properties +1 -0
- package/android/src/main/java/it/innove/BleManager.java +174 -148
- package/android/src/main/java/it/innove/BleManagerPackage.java +15 -14
- package/android/src/main/java/it/innove/CompanionScanner.java +13 -3
- package/android/src/main/java/it/innove/DefaultPeripheral.java +4 -4
- package/android/src/main/java/it/innove/DefaultScanManager.java +16 -16
- package/android/src/main/java/it/innove/Peripheral.java +20 -17
- package/dist/cjs/NativeBleManager.d.ts +241 -0
- package/dist/cjs/NativeBleManager.js +5 -0
- package/dist/cjs/NativeBleManager.js.map +1 -0
- package/dist/cjs/index.d.ts +15 -3
- package/dist/cjs/index.js +89 -38
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types.d.ts +11 -11
- package/dist/esm/NativeBleManager.d.ts +241 -0
- package/dist/esm/NativeBleManager.js +3 -0
- package/dist/esm/NativeBleManager.js.map +1 -0
- package/dist/esm/index.d.ts +15 -3
- package/dist/esm/index.js +92 -41
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types.d.ts +11 -11
- package/ios/BleManager-Bridging-Header.h +7 -1
- package/ios/BleManager.h +39 -2
- package/ios/BleManager.mm +277 -0
- package/ios/Helper.swift +6 -6
- package/ios/RNBleManager.h +7 -0
- package/ios/{BleManager.swift → SwiftBleManager.swift} +322 -355
- package/package.json +107 -56
- package/src/NativeBleManager.ts +409 -0
- package/src/index.ts +162 -77
- package/src/types.ts +31 -31
- package/android/src/main/java/it/innove/LegacyScanManager.java +0 -112
- package/ios/BleManager.m +0 -153
- package/ios/BleManager.xcodeproj/project.pbxproj +0 -324
- package/ios/BleManager.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/BleManager.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/react-native-ble-manager.podspec +0 -17
package/README.md
CHANGED
|
@@ -14,15 +14,16 @@ The library is a simple connection with the OS APIs, the BLE stack should be sta
|
|
|
14
14
|
|
|
15
15
|
## Requirements
|
|
16
16
|
|
|
17
|
-
RN 0.
|
|
17
|
+
RN 0.76+
|
|
18
18
|
|
|
19
|
+
RN 0.60-0.75 supported until 11.5.X
|
|
19
20
|
RN 0.40-0.59 supported until 6.7.X
|
|
20
21
|
RN 0.30-0.39 supported until 2.4.3
|
|
21
22
|
|
|
22
23
|
## Supported Platforms
|
|
23
24
|
|
|
24
|
-
- iOS
|
|
25
|
-
- Android (API
|
|
25
|
+
- iOS 15.1+
|
|
26
|
+
- Android (API 23+)
|
|
26
27
|
|
|
27
28
|
## Install
|
|
28
29
|
|
|
@@ -69,3 +70,15 @@ npm run build
|
|
|
69
70
|
```
|
|
70
71
|
|
|
71
72
|
> if you are modifying the typescript files of the library (in `src/`) on the fly, you can run `npm run watch` instead. If you are modifying files from the native counterparts, you'll need to rebuild the whole app for your target environnement (`npm run android/ios`).
|
|
73
|
+
|
|
74
|
+
## Generate the native code from specs
|
|
75
|
+
A react-native project is needed to generate the code via *codegen*.
|
|
76
|
+
|
|
77
|
+
#### Generate Android code
|
|
78
|
+
- in the example folder generate the android project from expo: `npx expo prebuild --platform android`
|
|
79
|
+
- in the example/android folder run: `./gradlew generateCodegenArtifactsFromSchema` (you can add --info to have debug messages)
|
|
80
|
+
- if you have problems with the gradle cache `cd android && ./gradlew --stop && rm -rf ~/.gradle/caches`
|
|
81
|
+
|
|
82
|
+
#### Generate iOS code
|
|
83
|
+
- in the example folder generate the ios project from expo: `npx expo prebuild --platform ios`
|
|
84
|
+
- the codegen run during the first build, if you need to run it again use `pod install` in the ios folder
|
|
@@ -0,0 +1,24 @@
|
|
|
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 = "RNBleManager"
|
|
7
|
+
s.summary = package['description']
|
|
8
|
+
s.version = package['version']
|
|
9
|
+
s.authors = package["author"]
|
|
10
|
+
s.homepage = package["homepage"]
|
|
11
|
+
s.license = package["license"]
|
|
12
|
+
s.platform = :ios, "11.0"
|
|
13
|
+
s.source = { :git => "https://github.com/innoveit/react-native-ble-manager.git" }
|
|
14
|
+
s.source_files = "ios/**/*.{h,mm,swift}"
|
|
15
|
+
|
|
16
|
+
s.static_framework = true
|
|
17
|
+
|
|
18
|
+
s.pod_target_xcconfig = {
|
|
19
|
+
'DEFINES_MODULE' => 'YES',
|
|
20
|
+
'SWIFT_COMPILATION_MODE' => 'wholemodule'
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
install_modules_dependencies(s)
|
|
24
|
+
end
|
package/android/build.gradle
CHANGED
|
@@ -1,59 +1,132 @@
|
|
|
1
1
|
buildscript {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
|
|
3
|
+
if (project == rootProject) {
|
|
4
|
+
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["kotlinVersion"]
|
|
5
|
+
|
|
6
|
+
repositories {
|
|
7
|
+
google()
|
|
8
|
+
mavenCentral()
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
dependencies {
|
|
12
|
+
classpath "com.android.tools.build:gradle:7.2.1"
|
|
13
|
+
// noinspection DifferentKotlinGradleVersion
|
|
14
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
15
18
|
}
|
|
19
|
+
|
|
20
|
+
def reactNativeArchitectures() {
|
|
21
|
+
def value = rootProject.getProperties().get("reactNativeArchitectures")
|
|
22
|
+
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
def isNewArchitectureEnabled() {
|
|
26
|
+
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
|
|
27
|
+
}
|
|
28
|
+
|
|
16
29
|
apply plugin: 'com.android.library'
|
|
30
|
+
apply plugin: "kotlin-android"
|
|
31
|
+
|
|
32
|
+
if (isNewArchitectureEnabled()) {
|
|
33
|
+
apply plugin: 'com.facebook.react'
|
|
34
|
+
}
|
|
17
35
|
|
|
18
36
|
def safeExtGet(prop, fallback) {
|
|
19
|
-
|
|
37
|
+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
def getExtOrDefault(name) {
|
|
41
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["BleManager_" + name]
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
static def supportsNamespace() {
|
|
45
|
+
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
|
|
46
|
+
def major = parsed[0].toInteger()
|
|
47
|
+
def minor = parsed[1].toInteger()
|
|
48
|
+
|
|
49
|
+
// Namespace support was added in 7.3.0
|
|
50
|
+
return (major == 7 && minor >= 3) || major >= 8
|
|
20
51
|
}
|
|
21
52
|
|
|
22
53
|
android {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
54
|
+
if (supportsNamespace()) {
|
|
55
|
+
namespace "it.innove"
|
|
56
|
+
|
|
57
|
+
sourceSets {
|
|
58
|
+
main {
|
|
59
|
+
manifest.srcFile "src/main/AndroidManifestNew.xml"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
compileSdk safeExtGet("compileSdk", 34)
|
|
65
|
+
|
|
66
|
+
compileOptions {
|
|
67
|
+
sourceCompatibility JavaVersion.VERSION_1_9
|
|
68
|
+
targetCompatibility JavaVersion.VERSION_1_9
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
defaultConfig {
|
|
72
|
+
minSdkVersion safeExtGet("minSdkVersion", 21)
|
|
73
|
+
targetSdk safeExtGet("targetSdk", 34)
|
|
74
|
+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
buildFeatures {
|
|
78
|
+
buildConfig true
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
buildTypes {
|
|
82
|
+
release {
|
|
83
|
+
minifyEnabled false
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
lintOptions {
|
|
88
|
+
disable "GradleCompatible"
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// To support legacy module in the future
|
|
92
|
+
/*
|
|
93
|
+
sourceSets {
|
|
94
|
+
main {
|
|
95
|
+
if (isNewArchitectureEnabled()) {
|
|
96
|
+
java.srcDirs += [
|
|
97
|
+
"src/newarch",
|
|
98
|
+
// Codegen specs
|
|
99
|
+
"generated/java",
|
|
100
|
+
"generated/jni"
|
|
101
|
+
]
|
|
102
|
+
} else {
|
|
103
|
+
java.srcDirs += ["src/oldarch"]
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
*/
|
|
42
108
|
}
|
|
43
109
|
|
|
110
|
+
|
|
44
111
|
repositories {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
jcenter()
|
|
48
|
-
maven {
|
|
49
|
-
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
|
|
50
|
-
//url "$rootDir/../node_modules/react-native/android"
|
|
51
|
-
url "$rootDir/../example/node_modules/react-native/android"
|
|
52
|
-
}
|
|
112
|
+
mavenCentral()
|
|
113
|
+
google()
|
|
53
114
|
}
|
|
54
115
|
|
|
116
|
+
def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
55
117
|
|
|
56
118
|
dependencies {
|
|
57
|
-
|
|
58
|
-
//
|
|
119
|
+
// For < 0.71, this will be from the local maven repo
|
|
120
|
+
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
|
|
121
|
+
//noinspection GradleDynamicVersion
|
|
122
|
+
implementation "com.facebook.react:react-native:+"
|
|
123
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
59
124
|
}
|
|
125
|
+
|
|
126
|
+
if (isNewArchitectureEnabled()) {
|
|
127
|
+
react {
|
|
128
|
+
jsRootDir = file("../src/")
|
|
129
|
+
libraryName = "BleManager"
|
|
130
|
+
codegenJavaPackageName = "it.innove"
|
|
131
|
+
}
|
|
132
|
+
}
|