diff --git a/README.md b/README.md index 5520821..ae02221 100644 --- a/README.md +++ b/README.md @@ -320,6 +320,8 @@ await DailyNotification.scheduleDualNotification({ }); ``` +If `contentFetch` omits `timeout`, `retryAttempts`, or `retryDelay`, Android applies defaults when scheduling fetch work (currently 30000 ms, 3 attempts, 1000 ms between attempts; see `FetchWorker`). + ### Callback Methods #### `registerCallback(name, config)` diff --git a/android/src/main/java/org/timesafari/dailynotification/DailyNotificationPlugin.kt b/android/src/main/java/org/timesafari/dailynotification/DailyNotificationPlugin.kt index 8d2fc93..6bbed41 100644 --- a/android/src/main/java/org/timesafari/dailynotification/DailyNotificationPlugin.kt +++ b/android/src/main/java/org/timesafari/dailynotification/DailyNotificationPlugin.kt @@ -2394,15 +2394,22 @@ open class DailyNotificationPlugin : Plugin() { } // Helper methods + /** + * Optional int from JSON: absent or JSON-null → null (aligns with TS `ContentFetchConfig` optional fields). + * [FetchWorker] applies defaults (e.g. 30000 / 3 / 1000) when null. + */ + private fun JSObject.optIntOrNull(key: String): Int? = + if (has(key) && !isNull(key)) optInt(key) else null + private fun parseContentFetchConfig(configJson: JSObject): ContentFetchConfig { val callbacksObj = configJson.getJSObject("callbacks") return ContentFetchConfig( enabled = configJson.getBoolean("enabled") ?: true, schedule = configJson.getString("schedule") ?: "0 9 * * *", url = configJson.getString("url"), - timeout = configJson.getInt("timeout"), - retryAttempts = configJson.getInt("retryAttempts"), - retryDelay = configJson.getInt("retryDelay"), + timeout = configJson.optIntOrNull("timeout"), + retryAttempts = configJson.optIntOrNull("retryAttempts"), + retryDelay = configJson.optIntOrNull("retryDelay"), callbacks = CallbackConfig( apiService = callbacksObj?.getString("apiService"), database = callbacksObj?.getString("database"),