Skip to content

Update Capacitor local-notifications patch for Capacitor v8 Swift API#475

Merged
BunsDev merged 4 commits intomainfrom
copilot/update-patch-capacitor-local-notifications
Apr 20, 2026
Merged

Update Capacitor local-notifications patch for Capacitor v8 Swift API#475
BunsDev merged 4 commits intomainfrom
copilot/update-patch-capacitor-local-notifications

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 20, 2026

  • Identify the open PR and confirm its conflict state against the base branch
  • Fetch the base branch with full history if needed and start conflict resolution on the PR head branch
  • Resolve merge conflicts while preserving the intended Capacitor local-notifications patch changes
  • Run targeted verification and required repository gates as far as the environment allows (targeted patch-script execution passed; full Bun gates remain blocked by registry/package-manifest failures in this environment)
  • Validate the resulting branch state and summarize any remaining blockers
Original prompt

The iOS build is failing due to compilation errors in @capacitor/local-notifications. The project is using Capacitor v8, but the plugin's Swift code (as patched by scripts/patch-capacitor-local-notifications.ts) is using an outdated API.

Specifically:

  1. call.getArray now requires a second argument (a default value) and returns a non-optional JSArray.
  2. CAPPluginCall no longer has a reject method; it has been replaced by unimplemented or resolve(JSObject) / error(String, String, Error, JSObject). Based on common patterns in Capacitor 6+, reject is typically replaced by call.error.

I need to update scripts/patch-capacitor-local-notifications.ts to:

  • Pass [] as the second argument to call.getArray.
  • Remove the optional chaining ?. from call.getArray(...) calls.
  • Replace call.reject(...) with call.error(...).

Modified REPLACEMENTS in scripts/patch-capacitor-local-notifications.ts should look like this:

const REPLACEMENTS: ReadonlyArray<[RegExp, string]> = [
  [
    /guard let notifications = call\.getArray\("notifications", JSObject\.self\) else \{/g,
    'guard let notifications = call.getArray("notifications", []).compactMap({ $0 as? JSObject }) else {',
  ],
  [
    /guard let notifications = call\.getArray\("notifications", JSObject\.self\), notifications\.count > 0 else \{/g,
    'guard let notifications = call.getArray("notifications", []).compactMap({ $0 as? JSObject }), notifications.count > 0 else {',
  ],
  [
    /guard let types = call\.getArray\("types", JSObject\.self\) else \{/g,
    'guard let types = call.getArray("types", []).compactMap({ $0 as? JSObject }) else {',
  ],
  [
    /call\.reject\(/g,
    'call.error(',
  ],
  [
    /return bridge\?\.localURL\(fromWebURL: webURL\)/g,
    [
      "        switch webURL.scheme {",
      '        case "res":',
      "            return bridge?.config.appLocation.appendingPathComponent(webURL.path)",
      '        case "file":',
      "            return webURL",
      "        default:",
      "            return nil",
      "        }",
    ].join("\n"),
  ],
];

Please apply these changes to scripts/patch-capacitor-local-notifications.ts.

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: Please find a solution for this failing job. Use the logs, job definition, and any referenced files where the failure occurred. Keep your response focused on the solution and include code suggestions when appropriate.

Assistant: The build failure in job 72082365800 is caused by compilation errors in the iOS source code of the @capacitor/local-notifications plugin. The error messages indicate that the Swift code is attempting to call getArray with only one argument, whereas the installed version of Capacitor requires a second argument (a default value). Additionally, the CAPPluginCall object is missing the reject method, suggesting a version mismatch between the plugin and the Capacitor core libraries.

Analysis of the Failure

The logs show multiple errors in LocalNotificationsPlugin.swift:

  1. Missing Argument: error: missing argument for parameter #2 in call when calling call.getArray("notifications").
  2. Optional Chaining Error: error: cannot use optional chaining on non-optional value because the new getArray signature returns a non-optional JSArray.
  3. Missing Member: error: value of type 'CAPPluginCall' has no member 'reject', which typically indicates the project is using a newer version of Capacitor where certain methods have been renamed or relocated.

The package.json contains a script specifically for patching this dependency: "patch:capacitor-local-notifications": "node scripts/patch-capacitor-local-notifications.ts". This suggests the issue is known and requires a local patch to maintain compatibility.

Proposed Solution

The failure occurs because the patch script is either not being run during the CI process or the patch itself is outdated for the version of Capacitor being used. You should update the patch script to correctly handle the getArray and reject signatures.

1. Update the Patch Script

Modify scripts/patch-capacitor-local-notifications.ts to ensure it correctly transforms the Swift code to match the Capacitor 6+ API requirements.

// scripts/patch-capacitor-local-notifications.ts (Partial suggestion)

const patchSwiftFile = (content: string) => {
  let patched = content;

  // 1. Fix getArray calls: add empty array as default value and remove optional chaining
  // From: call.getArray("notifications")?.
  // To:   call.getArray("notifications", [])?. -> Note: if it's non-optional now, remove '?'
  patched = patched.replace(
    /call\.getArray\("(.+?)"\)\?/g,
    'call.getArray("$1", [])'
  );

  // 2. Fix reject calls: Capacitor 6 uses call.unavailable() or call.error() 
  // or requires specific formatting if 'reject' was removed from ...

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

*This pull request was created from Copilot chat.*
>

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 20, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
okcode-marketing Ready Ready Preview Apr 20, 2026 8:08am
v0-compute-the-platform-to-build Error Error Apr 20, 2026 8:08am

Copilot AI changed the title [WIP] Update patch-capacitor-local-notifications for API changes Update Capacitor local-notifications patch for Capacitor v8 Swift API Apr 20, 2026
Copilot AI requested a review from BunsDev April 20, 2026 07:36
Agent-Logs-Url: https://github.com/OpenKnots/okcode/sessions/c09e6a8c-001f-4ada-a5f7-e3b0018da8f4

Co-authored-by: BunsDev <68980965+BunsDev@users.noreply.github.com>
@BunsDev BunsDev marked this pull request as ready for review April 20, 2026 08:07
@github-actions github-actions bot added the vouch:unvouched PR author is not yet trusted in the VOUCHED list. label Apr 20, 2026
@BunsDev BunsDev merged commit c2e546d into main Apr 20, 2026
13 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants