Skip to content

Commit 3484f95

Browse files
author
Nishanth Bhat
committed
fix: fixed type issue in kotlin
1 parent b8c8ef8 commit 3484f95

File tree

10 files changed

+1891
-30
lines changed

10 files changed

+1891
-30
lines changed

android/src/main/java/com/backgroundsync/scheduler/PeriodicScheduler.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ class PeriodicScheduler(private val workManager: WorkManager?) {
1818
.setRequiredNetworkType(NetworkType.CONNECTED)
1919
.build()
2020

21-
val syncInterval=params.getInt("syncInterval")
21+
val syncInterval=params.getInt("syncInterval").toLong()
2222
val syncIntervalType=params.getString("syncIntervalType")
23-
val syncFlexTime=params.getInt("syncFlexTime")
23+
val syncFlexTime=params.getInt("syncFlexTime").toLong()
2424
val syncFlexTimeType=params.getString("syncFlexTimeType")
2525
val taskKey=params.getString("taskKey")
2626
val workerPolicy=params.getString("workerPolicy")
@@ -29,9 +29,9 @@ class PeriodicScheduler(private val workManager: WorkManager?) {
2929

3030
val periodicWorkRequest = PeriodicWorkRequest.Builder(
3131
BackgroundSyncWorker::class.java,
32-
syncInterval as Long,
32+
syncInterval,
3333
convertToTimeUnit(syncIntervalType),
34-
syncFlexTime as Long,
34+
syncFlexTime,
3535
convertToTimeUnit(syncFlexTimeType)
3636
).setConstraints(constraints).setInputData(headlessConfig).addTag(taskKey as String).build()
3737

android/src/main/java/com/backgroundsync/utils/WorkerUtils.kt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,15 @@ fun convertWorkerPolicy(type: String?): ExistingPeriodicWorkPolicy {
3636

3737

3838
fun generateHeadlessConfig(params: ReadableMap): Data {
39-
return Data.Builder()
40-
.putInt("maxRetryAttempts", params.getInt("maxRetryAttempts"))
41-
.putLong("retryDelay", params.getDouble("retryDelay").toLong())
42-
.putLong("taskTimeout", params.getDouble("taskTimeout").toLong())
43-
.putBoolean("allowedInForeground", params.getBoolean("allowedInForeground"))
39+
val config = Data.Builder()
4440
.putString("taskKey", params.getString("taskKey"))
45-
.build()
41+
42+
if(params.hasKey("maxRetryAttempts")) config.putInt("maxRetryAttempts", params.getInt("maxRetryAttempts"))
43+
if(params.hasKey("retryDelay")) config.putInt("retryDelay", params.getDouble("retryDelay").toInt())
44+
if(params.hasKey("taskTimeout")) config.putLong("taskTimeout", params.getDouble("taskTimeout").toLong())
45+
if(params.hasKey("allowedInForeground")) config.putBoolean("allowedInForeground", params.getBoolean("allowedInForeground"))
46+
47+
return config.build()
4648
}
4749

4850
fun isWorkScheduled(workManager: WorkManager?,tag: String?): Boolean {

android/src/main/java/com/backgroundsync/worker/BackgroundWorker.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.backgroundsync.worker
22

33
import android.content.Context
4+
import android.util.Log
45
import androidx.work.Data
56
import androidx.work.WorkerParameters
67
import com.facebook.react.bridge.Arguments
@@ -11,9 +12,10 @@ import com.facebook.react.jstasks.LinearCountingRetryPolicy
1112
class BackgroundSyncWorker(context: Context, workerParams: WorkerParameters) :
1213
HeadlessWorker(context, workerParams) {
1314
override fun getTaskConfig(data: Data?): HeadlessJsTaskConfig? {
15+
Log.d("TAG", "getTaskConfig: $data")
1416
val taskKey= data?.getString("taskKey")
1517
val maxRetryAttempts = data?.getInt("maxRetryAttempts", 3)
16-
val retryDelay = data?.getLong("retryDelay", 4000L)
18+
val retryDelay = data?.getInt("retryDelay", 4000)
1719
val taskTimeout = data?.getLong("taskTimeout", 10000L)
1820
val allowedInForeground = data?.getBoolean("allowedInForeground", true)
1921

example/ios/.xcode.env.local

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export NODE_BINARY=/Users/nishanthbhat/.nvm/versions/node/v18.18.2/bin/node

example/ios/BackgroundSyncExample.xcodeproj/project.pbxproj

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
1515
7699B88040F8A987B510C191 /* libPods-BackgroundSyncExample-BackgroundSyncExampleTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 19F6CBCC0A4E27FBF8BF4A61 /* libPods-BackgroundSyncExample-BackgroundSyncExampleTests.a */; };
1616
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; };
17+
823584AB6293587DB3642C79 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 6A9C6C55198990393173BF9B /* PrivacyInfo.xcprivacy */; };
1718
/* End PBXBuildFile section */
1819

1920
/* Begin PBXContainerItemProxy section */
@@ -42,6 +43,7 @@
4243
5709B34CF0A7D63546082F79 /* Pods-BackgroundSyncExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BackgroundSyncExample.release.xcconfig"; path = "Target Support Files/Pods-BackgroundSyncExample/Pods-BackgroundSyncExample.release.xcconfig"; sourceTree = "<group>"; };
4344
5B7EB9410499542E8C5724F5 /* Pods-BackgroundSyncExample-BackgroundSyncExampleTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BackgroundSyncExample-BackgroundSyncExampleTests.debug.xcconfig"; path = "Target Support Files/Pods-BackgroundSyncExample-BackgroundSyncExampleTests/Pods-BackgroundSyncExample-BackgroundSyncExampleTests.debug.xcconfig"; sourceTree = "<group>"; };
4445
5DCACB8F33CDC322A6C60F78 /* libPods-BackgroundSyncExample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-BackgroundSyncExample.a"; sourceTree = BUILT_PRODUCTS_DIR; };
46+
6A9C6C55198990393173BF9B /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; includeInIndex = 1; name = PrivacyInfo.xcprivacy; path = BackgroundSyncExample/PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
4547
81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = BackgroundSyncExample/LaunchScreen.storyboard; sourceTree = "<group>"; };
4648
89C6BE57DB24E9ADA2F236DE /* Pods-BackgroundSyncExample-BackgroundSyncExampleTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BackgroundSyncExample-BackgroundSyncExampleTests.release.xcconfig"; path = "Target Support Files/Pods-BackgroundSyncExample-BackgroundSyncExampleTests/Pods-BackgroundSyncExample-BackgroundSyncExampleTests.release.xcconfig"; sourceTree = "<group>"; };
4749
ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
@@ -94,6 +96,7 @@
9496
81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */,
9597
13B07FB71A68108700A75B9A /* main.m */,
9698
13B07FB81A68108700A75B9A /* PrivacyInfo.xcprivacy */,
99+
6A9C6C55198990393173BF9B /* PrivacyInfo.xcprivacy */,
97100
);
98101
name = BackgroundSyncExample;
99102
sourceTree = "<group>";
@@ -245,6 +248,7 @@
245248
files = (
246249
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */,
247250
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */,
251+
823584AB6293587DB3642C79 /* PrivacyInfo.xcprivacy in Resources */,
248252
);
249253
runOnlyForDeploymentPostprocessing = 0;
250254
};
@@ -431,7 +435,7 @@
431435
"-lc++",
432436
"$(inherited)",
433437
);
434-
PRODUCT_BUNDLE_IDENTIFIER = "backgroundsync.example";
438+
PRODUCT_BUNDLE_IDENTIFIER = backgroundsync.example;
435439
PRODUCT_NAME = "$(TARGET_NAME)";
436440
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/BackgroundSyncExample.app/BackgroundSyncExample";
437441
};
@@ -455,7 +459,7 @@
455459
"-lc++",
456460
"$(inherited)",
457461
);
458-
PRODUCT_BUNDLE_IDENTIFIER = "backgroundsync.example";
462+
PRODUCT_BUNDLE_IDENTIFIER = backgroundsync.example;
459463
PRODUCT_NAME = "$(TARGET_NAME)";
460464
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/BackgroundSyncExample.app/BackgroundSyncExample";
461465
};
@@ -480,7 +484,7 @@
480484
"-ObjC",
481485
"-lc++",
482486
);
483-
PRODUCT_BUNDLE_IDENTIFIER = "backgroundsync.example";
487+
PRODUCT_BUNDLE_IDENTIFIER = backgroundsync.example;
484488
PRODUCT_NAME = BackgroundSyncExample;
485489
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
486490
SWIFT_VERSION = 5.0;
@@ -506,7 +510,7 @@
506510
"-ObjC",
507511
"-lc++",
508512
);
509-
PRODUCT_BUNDLE_IDENTIFIER = "backgroundsync.example";
513+
PRODUCT_BUNDLE_IDENTIFIER = backgroundsync.example;
510514
PRODUCT_NAME = BackgroundSyncExample;
511515
SWIFT_VERSION = 5.0;
512516
VERSIONING_SYSTEM = "apple-generic";
@@ -582,7 +586,14 @@
582586
"-DFOLLY_CFG_NO_COROUTINES=1",
583587
"-DFOLLY_HAVE_CLOCK_GETTIME=1",
584588
);
589+
OTHER_LDFLAGS = (
590+
"$(inherited)",
591+
" ",
592+
);
593+
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
585594
SDKROOT = iphoneos;
595+
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) DEBUG";
596+
USE_HERMES = true;
586597
};
587598
name = Debug;
588599
};
@@ -647,7 +658,13 @@
647658
"-DFOLLY_CFG_NO_COROUTINES=1",
648659
"-DFOLLY_HAVE_CLOCK_GETTIME=1",
649660
);
661+
OTHER_LDFLAGS = (
662+
"$(inherited)",
663+
" ",
664+
);
665+
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
650666
SDKROOT = iphoneos;
667+
USE_HERMES = true;
651668
VALIDATE_PRODUCT = YES;
652669
};
653670
name = Release;

example/ios/BackgroundSyncExample.xcworkspace/contents.xcworkspacedata

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)