@ovok/native 1.6.7 → 1.6.8
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/android/build.gradle
CHANGED
|
@@ -35,9 +35,12 @@ repositories {
|
|
|
35
35
|
mavenCentral()
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
def reactNativeDependency = rootProject.findProperty("reactNativeDependency")
|
|
39
|
+
?: "com.facebook.react:react-native:+"
|
|
40
|
+
|
|
38
41
|
dependencies {
|
|
39
42
|
// For modern React Native this is resolved by the React Gradle plugin.
|
|
40
|
-
implementation
|
|
43
|
+
implementation reactNativeDependency
|
|
41
44
|
implementation "androidx.core:core:1.13.1"
|
|
42
45
|
implementation "androidx.work:work-runtime:2.10.1"
|
|
43
46
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
android.useAndroidX=true
|
|
@@ -2,7 +2,6 @@ package com.ovok.sdk.backgroundsync;
|
|
|
2
2
|
|
|
3
3
|
import android.app.Activity;
|
|
4
4
|
import android.content.Context;
|
|
5
|
-
import android.content.ComponentName;
|
|
6
5
|
import android.content.Intent;
|
|
7
6
|
import android.net.Uri;
|
|
8
7
|
import android.os.Build;
|
|
@@ -47,13 +46,9 @@ public final class OvokBackgroundSyncModule extends ReactContextBaseJavaModule {
|
|
|
47
46
|
BackgroundSyncNotification.save(context, options, "bluetooth");
|
|
48
47
|
|
|
49
48
|
Intent intent = new Intent(context, OvokBluetoothForegroundService.class);
|
|
50
|
-
ComponentName started;
|
|
51
49
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
52
|
-
|
|
53
|
-
} else {
|
|
54
|
-
started = context.startService(intent);
|
|
55
|
-
}
|
|
56
|
-
if (started == null) {
|
|
50
|
+
ContextCompat.startForegroundService(context, intent);
|
|
51
|
+
} else if (context.startService(intent) == null) {
|
|
57
52
|
throw new IllegalStateException("Bluetooth foreground service was not found");
|
|
58
53
|
}
|
|
59
54
|
|
|
@@ -94,7 +89,7 @@ public final class OvokBackgroundSyncModule extends ReactContextBaseJavaModule {
|
|
|
94
89
|
@ReactMethod
|
|
95
90
|
public void requestIgnoreBatteryOptimizations(Promise promise) {
|
|
96
91
|
try {
|
|
97
|
-
|
|
92
|
+
ReactApplicationContext context = getReactApplicationContext();
|
|
98
93
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
|
99
94
|
promise.resolve(true);
|
|
100
95
|
return;
|
|
@@ -135,7 +130,7 @@ public final class OvokBackgroundSyncModule extends ReactContextBaseJavaModule {
|
|
|
135
130
|
promise.resolve(false);
|
|
136
131
|
} catch (Exception error) {
|
|
137
132
|
try {
|
|
138
|
-
|
|
133
|
+
ReactApplicationContext context = getReactApplicationContext();
|
|
139
134
|
if (context.getLifecycleState() != LifecycleState.RESUMED) {
|
|
140
135
|
promise.resolve(false);
|
|
141
136
|
return;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
package com.ovok.sdk.backgroundsync;
|
|
2
2
|
|
|
3
3
|
import android.content.Context;
|
|
4
|
-
import android.content.ComponentName;
|
|
5
4
|
import android.content.Intent;
|
|
6
5
|
import androidx.annotation.NonNull;
|
|
7
6
|
import androidx.core.content.ContextCompat;
|
|
@@ -20,10 +19,7 @@ public final class OvokHealthConnectWorker extends Worker {
|
|
|
20
19
|
Context context = getApplicationContext();
|
|
21
20
|
Intent intent = new Intent(context, OvokHealthConnectTaskService.class);
|
|
22
21
|
intent.putExtra("reason", "periodic-work");
|
|
23
|
-
|
|
24
|
-
if (started == null) {
|
|
25
|
-
return Result.failure();
|
|
26
|
-
}
|
|
22
|
+
ContextCompat.startForegroundService(context, intent);
|
|
27
23
|
return Result.success();
|
|
28
24
|
} catch (Exception error) {
|
|
29
25
|
return Result.failure();
|