fix(ios): configure method parameter parsing and improve build process

Fix configure() method to read parameters directly from CAPPluginCall
instead of expecting nested options object, matching Android implementation.

Improve build process to ensure canonical UI is always copied:
- iOS build script: Copy www/index.html to test app before build
- Android build.gradle: Add copyCanonicalUI task to run before build
- Ensures test apps always use latest UI from www/index.html

This fixes the issue where configure() was returning 'Configuration
options required' error because it expected a nested options object
when Capacitor passes parameters directly on the call object.
This commit is contained in:
Matthew
2025-11-19 20:09:01 -08:00
parent 3d9254e26d
commit 92bb566631
5 changed files with 822 additions and 1149 deletions

View File

@@ -80,24 +80,21 @@ public class DailyNotificationPlugin: CAPPlugin {
* @param call Plugin call containing configuration parameters
*/
@objc func configure(_ call: CAPPluginCall) {
guard let options = call.getObject("options") else {
call.reject("Configuration options required")
return
}
// Capacitor passes the options object directly as call data
// Read parameters directly from call (matching Android implementation)
print("DNP-PLUGIN: Configuring plugin with new options")
do {
// Get configuration options
let dbPath = options["dbPath"] as? String
let storageMode = options["storage"] as? String ?? "tiered"
let ttlSeconds = options["ttlSeconds"] as? Int
let prefetchLeadMinutes = options["prefetchLeadMinutes"] as? Int
let maxNotificationsPerDay = options["maxNotificationsPerDay"] as? Int
let retentionDays = options["retentionDays"] as? Int
// Get configuration options directly from call (matching Android)
let dbPath = call.getString("dbPath")
let storageMode = call.getString("storage") ?? "tiered"
let ttlSeconds = call.getInt("ttlSeconds")
let prefetchLeadMinutes = call.getInt("prefetchLeadMinutes")
let maxNotificationsPerDay = call.getInt("maxNotificationsPerDay")
let retentionDays = call.getInt("retentionDays")
// Phase 1: Process activeDidIntegration configuration (deferred to Phase 3)
if let activeDidConfig = options["activeDidIntegration"] as? [String: Any] {
if let activeDidConfig = call.getObject("activeDidIntegration") {
print("DNP-PLUGIN: activeDidIntegration config received (Phase 3 feature)")
// TODO: Implement activeDidIntegration configuration in Phase 3
}
@@ -1486,7 +1483,7 @@ public class DailyNotificationPlugin: CAPPlugin {
var methods: [CAPPluginMethod] = []
// Core methods
methods.append(CAPPluginMethod(name: "configure", returnType: CAPPluginReturnNone))
methods.append(CAPPluginMethod(name: "configure", returnType: CAPPluginReturnPromise))
methods.append(CAPPluginMethod(name: "scheduleDailyNotification", returnType: CAPPluginReturnPromise))
methods.append(CAPPluginMethod(name: "getLastNotification", returnType: CAPPluginReturnPromise))
methods.append(CAPPluginMethod(name: "cancelAllNotifications", returnType: CAPPluginReturnPromise))