feat!: rename batch APIs to scheduleApiNotifications and clearApiNotifications

BREAKING CHANGE: Replaces scheduleNotifications, clearPredictiveNotifications,
and iOS clearAllNotifications. Behavior and api_ IDs unchanged.
This commit is contained in:
Jose Olarte III
2026-06-09 18:10:14 +08:00
parent 6de300b7d4
commit d4da7256a5
5 changed files with 29 additions and 28 deletions

View File

@@ -9,13 +9,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- **Android**: `scheduleNotifications` batch API schedules one-shot notifications at epoch-ms timestamps using deterministic `api_<epochMillis>` schedule IDs.
- **Android**: `clearPredictiveNotifications` cancels only API-managed schedules (`api_*`) without affecting Daily Reminders, user schedules, dual schedules, or fetch jobs.
- **Android / iOS**: `scheduleApiNotifications` batch API schedules one-shot notifications at epoch-ms timestamps using deterministic `api_<epochMillis>` identifiers.
- **Android / iOS**: `clearApiNotifications` cancels or removes only API-managed notifications (`api_*`) without affecting Daily Reminders, user schedules, dual schedules, or fetch jobs.
### Changed
- **Android / iOS**: Internal batch notification ID namespace renamed from `predictive_<epochMillis>` to `api_<epochMillis>`. Public Capacitor method names are unchanged; scheduling and lifecycle behavior are unchanged.
- **TypeScript**: JSDoc for `scheduleNotifications` and `clearPredictiveNotifications` updated to document `api_*` identifiers.
- **Android / iOS**: Internal batch notification ID namespace renamed from `predictive_<epochMillis>` to `api_<epochMillis>`. Scheduling and lifecycle behavior are unchanged.
- **Breaking**: Public batch APIs renamed from `scheduleNotifications` / `clearPredictiveNotifications` / `clearAllNotifications` to `scheduleApiNotifications` / `clearApiNotifications`.
- **TypeScript**: JSDoc updated to document `api_*` identifiers and API terminology.
## [3.0.3] - 2026-05-22
@@ -29,13 +30,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- **iOS**: Predictive notification identifiers use epoch **milliseconds** (`predictive_<timestamp>`). Daily reminders persist `predictiveEpochMillis` for cancel/update alignment.
- **iOS**: `clearAllNotifications` removes only **`predictive_*`** pending and delivered notifications (dual/org IDs unchanged).
- **iOS**: `scheduleNotifications` is additive only (no automatic clear); skips stale timestamps in the past.
- **iOS**: API notification identifiers use epoch **milliseconds** (`api_<timestamp>`). Daily reminders persist `predictiveEpochMillis` for cancel/update alignment.
- **iOS**: `clearApiNotifications` removes only **`api_*`** pending and delivered notifications (dual/org IDs unchanged).
- **iOS**: `scheduleApiNotifications` is additive only (no automatic clear); skips stale timestamps in the past.
### Added
- **iOS**: `clearAllNotifications` and `scheduleNotifications` batch APIs on `DailyNotification` (Capacitor).
- **iOS**: `clearApiNotifications` and `scheduleApiNotifications` batch APIs on `DailyNotification` (Capacitor).
## [3.0.1] - 2026-04-16

View File

@@ -746,10 +746,10 @@ open class DailyNotificationPlugin : Plugin() {
/**
* Add one-shot API-managed notifications at epoch-ms timestamps (additive; does not clear others).
* Caller should invoke [clearPredictiveNotifications] first when replacing a full batch.
* Caller should invoke [clearApiNotifications] first when replacing a full batch.
*/
@PluginMethod
fun scheduleNotifications(call: PluginCall) {
fun scheduleApiNotifications(call: PluginCall) {
val timestampsArray = call.getArray("timestamps")
if (timestampsArray == null) {
call.reject("Missing timestamps")
@@ -761,7 +761,7 @@ open class DailyNotificationPlugin : Plugin() {
if (context == null) {
return@launch call.reject("Context not available")
}
Log.i(TAG, "DNP-BATCH: scheduleNotifications — additive scheduling for ${timestampsArray.length()} timestamp(s)")
Log.i(TAG, "DNP-BATCH: scheduleApiNotifications — additive scheduling for ${timestampsArray.length()} timestamp(s)")
var scheduledCount = 0
for (i in 0 until timestampsArray.length()) {
@@ -775,7 +775,7 @@ open class DailyNotificationPlugin : Plugin() {
}
}
Log.i(TAG, "DNP-BATCH: scheduleNotifications done scheduled=$scheduledCount/${timestampsArray.length()}")
Log.i(TAG, "DNP-BATCH: scheduleApiNotifications done scheduled=$scheduledCount/${timestampsArray.length()}")
call.resolve()
} catch (e: Exception) {
Log.e(TAG, "Failed to schedule notifications", e)
@@ -789,7 +789,7 @@ open class DailyNotificationPlugin : Plugin() {
* Does not affect Daily Reminders, user-created schedules, dual schedules, or fetch jobs.
*/
@PluginMethod
fun clearPredictiveNotifications(call: PluginCall) {
fun clearApiNotifications(call: PluginCall) {
CoroutineScope(Dispatchers.IO).launch {
try {
if (context == null) {

View File

@@ -1121,9 +1121,9 @@ public class DailyNotificationPlugin: CAPPlugin {
// MARK: - API batch notifications (replace-all UNUserNotificationCenter)
/// Removes only pending and delivered notifications whose identifiers begin with `api_`. Does not touch dual/org IDs or other stacks.
@objc func clearAllNotifications(_ call: CAPPluginCall) {
NSLog("DNP-BATCH: clearAllNotifications — removing api_* pending and delivered only")
print("DNP-BATCH: clearAllNotifications — removing api_* pending and delivered only")
@objc func clearApiNotifications(_ call: CAPPluginCall) {
NSLog("DNP-BATCH: clearApiNotifications — removing api_* pending and delivered only")
print("DNP-BATCH: clearApiNotifications — removing api_* pending and delivered only")
let center = notificationCenter
let prefix = apiNotificationPrefix
let group = DispatchGroup()
@@ -1154,14 +1154,14 @@ public class DailyNotificationPlugin: CAPPlugin {
/// Add one-shot reminders at epoch-ms timestamps. Does not remove other requests; identical IDs replace pending entries. Caller should clear first if needed.
/// Adds/overwrites API-managed notifications using deterministic IDs.
/// Does NOT clear existing notifications. Caller is responsible for lifecycle.
@objc func scheduleNotifications(_ call: CAPPluginCall) {
@objc func scheduleApiNotifications(_ call: CAPPluginCall) {
guard let timestamps = call.getArray("timestamps", Double.self) else {
call.reject("Missing timestamps")
return
}
NSLog("DNP-BATCH: scheduleNotifications — additive scheduling for \(timestamps.count) timestamp(s)")
print("DNP-BATCH: scheduleNotifications — additive scheduling for \(timestamps.count) timestamp(s)")
NSLog("DNP-BATCH: scheduleApiNotifications — additive scheduling for \(timestamps.count) timestamp(s)")
print("DNP-BATCH: scheduleApiNotifications — additive scheduling for \(timestamps.count) timestamp(s)")
for ts in timestamps {
let date = Date(timeIntervalSince1970: ts / 1000)
@@ -2793,8 +2793,8 @@ extension DailyNotificationPlugin {
methods.append(CAPPluginMethod(name: "updateDailyReminder", returnType: CAPPluginReturnPromise))
// API batch notifications (replace-all UNUserNotificationCenter)
methods.append(CAPPluginMethod(name: "clearAllNotifications", returnType: CAPPluginReturnPromise))
methods.append(CAPPluginMethod(name: "scheduleNotifications", returnType: CAPPluginReturnPromise))
methods.append(CAPPluginMethod(name: "clearApiNotifications", returnType: CAPPluginReturnPromise))
methods.append(CAPPluginMethod(name: "scheduleApiNotifications", returnType: CAPPluginReturnPromise))
// Dual scheduling methods
methods.append(CAPPluginMethod(name: "scheduleContentFetch", returnType: CAPPluginReturnPromise))

View File

@@ -604,14 +604,14 @@ export interface DailyNotificationPlugin {
cancelAllNotifications(): Promise<void>;
/**
* Add one-shot API-managed notifications at epoch-ms timestamps (additive).
* Android uses `api_<timestamp>` schedule IDs; caller should clear first when replacing a batch.
* Uses `api_<timestamp>` identifiers; caller should clear first when replacing a batch.
*/
scheduleNotifications(options: { timestamps: number[] }): Promise<void>;
scheduleApiNotifications(options: { timestamps: number[] }): Promise<void>;
/**
* Android only: cancel API-managed notification schedules (`api_*`) without
* affecting Daily Reminders, user schedules, dual schedules, or fetch jobs.
* Cancel API-managed notifications (`api_*`) without affecting Daily Reminders,
* user schedules, dual schedules, or fetch jobs.
*/
clearPredictiveNotifications(): Promise<void>;
clearApiNotifications(): Promise<void>;
getNotificationStatus(): Promise<NotificationStatus>;
updateSettings(settings: NotificationSettings): Promise<void>;
getBatteryStatus(): Promise<BatteryStatus>;

View File

@@ -118,11 +118,11 @@ export class DailyNotificationWeb implements DailyNotificationPlugin {
this.throwNotSupported();
}
async scheduleNotifications(): Promise<void> {
async scheduleApiNotifications(): Promise<void> {
this.throwNotSupported();
}
async clearPredictiveNotifications(): Promise<void> {
async clearApiNotifications(): Promise<void> {
this.throwNotSupported();
}