Skip to content

feat: Add support for notification push type widgets#194

Open
dwrss wants to merge 3 commits intoparse-community:masterfrom
Snailed-It:add-widgets-to-NotificationPushType
Open

feat: Add support for notification push type widgets#194
dwrss wants to merge 3 commits intoparse-community:masterfrom
Snailed-It:add-widgets-to-NotificationPushType

Conversation

@dwrss
Copy link
Copy Markdown

@dwrss dwrss commented Jan 7, 2026

As per Apple's documentation "widgets" is now a valid push type: https://developer.apple.com/documentation/widgetkit/updating-widgets-with-widgetkit-push-notifications

Summary by CodeRabbit

  • New Features

    • Added support for a new "widgets" notification type.
    • Added a public "content changed" flag for notifications; enabling it includes the corresponding APS field in outgoing payloads and provides a chainable setter.
  • Tests

    • Added tests validating the content-changed flag’s default omission, setting behavior (true/1), removal, and setter chaining.

@parse-github-assistant
Copy link
Copy Markdown

parse-github-assistant bot commented Jan 7, 2026

🚀 Thanks for opening this pull request! We appreciate your effort in improving the project. Please let us know once your pull request is ready for review.

Tip

  • Keep pull requests small. Large PRs will be rejected. Break complex features into smaller, incremental PRs.
  • Use Test Driven Development. Write failing tests before implementing functionality. Ensure tests pass.
  • Group code into logical blocks. Add a short comment before each block to explain its purpose.
  • We offer conceptual guidance. Coding is up to you. PRs must be merge-ready for human review.
  • Our review focuses on concept, not quality. PRs with code issues will be rejected. Use an AI agent.
  • Human review time is precious. Avoid review ping-pong. Inspect and test your AI-generated code.

Note

Please respond to review comments from AI agents just like you would to comments from a human reviewer. Let the reviewer resolve their own comments, unless they have reviewed and accepted your commit, or agreed with your explanation for why the feedback was incorrect.

Caution

Pull requests must be written using an AI agent with human supervision. Pull requests written entirely by a human will likely be rejected, because of lower code quality, higher review effort and the higher risk of introducing bugs. Please note that AI review comments on this pull request alone do not satisfy this requirement.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jan 7, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9868dc15-0569-4d82-83eb-b01d9a424cf6

📥 Commits

Reviewing files that changed from the base of the PR and between d059556 and 29c6a90.

📒 Files selected for processing (4)
  • index.d.ts
  • lib/notification/apsProperties.js
  • lib/notification/index.js
  • test/notification/apsProperties.js
✅ Files skipped from review due to trivial changes (1)
  • test/notification/apsProperties.js
🚧 Files skipped from review as they are similar to previous changes (2)
  • lib/notification/index.js
  • index.d.ts

📝 Walkthrough

Walkthrough

Adds APS support for a "content-changed" flag: TypeScript typings extended, runtime APS setter added, a generated chainable setContentChanged on Notification, and unit tests; also adds 'widgets' to the exported NotificationPushType union.

Changes

Cohort / File(s) Summary
Type Definitions
index.d.ts
Added optional `"content-changed"?: undefined
APS runtime property
lib/notification/apsProperties.js
Added exported contentChanged setter: sets this.aps['content-changed'] = true when input is true or 1, otherwise clears the field (undefined).
Notification API
lib/notification/index.js
Added contentChanged to the properties list so a chainable setContentChanged(value) setter is generated on Notification.prototype.
Tests
test/notification/apsProperties.js
Added tests verifying default omission, setting to true, normalization from 1, clearing to undefined, and that setContentChanged(true) is chainable and produces aps.content-changed: true in compiled payload.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Engage In Review Feedback ❓ Inconclusive The custom check requires assessing whether the PR author has engaged with review feedback comments, but no review comments or discussions are accessible in the provided context. Please provide GitHub PR review comments, discussion threads, or metadata to assess engagement with review feedback.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title begins with the required 'feat:' prefix and clearly summarizes the main changes: adding support for the 'widgets' push type to the notification system.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Security Check ✅ Passed The PR introduces no security vulnerabilities. Changes add a new contentChanged property following established safe coding patterns with strict input validation.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@parseplatformorg
Copy link
Copy Markdown

parseplatformorg commented Jan 7, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @index.d.ts:
- Line 270: The union type NotificationPushType includes an invalid value
'widgets'; remove 'widgets' from the NotificationPushType declaration so the
type union matches Apple APNs valid push types (alert, background, location,
voip, complication, fileprovider, mdm, liveactivity, pushtotalk). Also audit the
code that sets the apns-push-type header (the logic around pushType usage in
lib/notification/index.js) and, if needed, add validation to reject or map
unsupported values before sending to APNs so only documented types are allowed.
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c49e689 and 4075937.

📒 Files selected for processing (1)
  • index.d.ts

@dwrss dwrss changed the title Add 'widgets' to NotificationPushType feat: Allow 'widgets' in NotificationPushType Jan 8, 2026
coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 8, 2026
Copy link
Copy Markdown
Member

@mtrezza mtrezza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test is missing

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.87%. Comparing base (d436b79) to head (29c6a90).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #194      +/-   ##
==========================================
+ Coverage   95.86%   95.87%   +0.01%     
==========================================
  Files          23       23              
  Lines         846      849       +3     
==========================================
+ Hits          811      814       +3     
  Misses         35       35              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mtrezza mtrezza changed the title feat: Allow 'widgets' in NotificationPushType feat: Add support for notification push type widgets Mar 31, 2026
@dwrss dwrss force-pushed the add-widgets-to-NotificationPushType branch from d102112 to d059556 Compare April 1, 2026 22:53
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@index.d.ts`:
- Around line 370-373: The declaration for contentChanged currently uses boolean
but the runtime setter (see lib/notification/apsProperties.js) treats allowed
set values as true | 1 and clears the field on undefined/other falsy values;
update the index.d.ts declaration for the public property contentChanged to
reflect the runtime contract (allow true and numeric 1 as valid set values and
undefined to clear) so TypeScript callers can express setting and clearing
correctly (locate the contentChanged property in the type/class declaration and
change its type accordingly).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a7909c75-4ee3-4280-b713-64be07eabf0a

📥 Commits

Reviewing files that changed from the base of the PR and between d102112 and d059556.

📒 Files selected for processing (4)
  • index.d.ts
  • lib/notification/apsProperties.js
  • lib/notification/index.js
  • test/notification/apsProperties.js
✅ Files skipped from review due to trivial changes (2)
  • lib/notification/apsProperties.js
  • test/notification/apsProperties.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • lib/notification/index.js

Comment on lines +370 to +373
/**
* Setting this to true will specify "content-changed" in the payload when it is compiled
*/
public contentChanged: boolean;
Copy link
Copy Markdown

@coderabbitai coderabbitai bot Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify declaration/runtime/test contract for contentChanged
rg -n "contentChanged|content-changed" index.d.ts lib/notification/apsProperties.js test/notification/apsProperties.js -C3

Repository: parse-community/node-apn

Length of output: 3811


Widen contentChanged type to match runtime setter behavior.

Line 373 declares contentChanged as boolean, but the runtime setter (lib/notification/apsProperties.js:148–154) accepts true | 1 and clears on undefined and other falsy values. TS users cannot currently express the full contract.

Proposed typing fix
-  public contentChanged: boolean;
+  public contentChanged: boolean | 1 | undefined;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/**
* Setting this to true will specify "content-changed" in the payload when it is compiled
*/
public contentChanged: boolean;
/**
* Setting this to true will specify "content-changed" in the payload when it is compiled
*/
public contentChanged: boolean | 1 | undefined;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@index.d.ts` around lines 370 - 373, The declaration for contentChanged
currently uses boolean but the runtime setter (see
lib/notification/apsProperties.js) treats allowed set values as true | 1 and
clears the field on undefined/other falsy values; update the index.d.ts
declaration for the public property contentChanged to reflect the runtime
contract (allow true and numeric 1 as valid set values and undefined to clear)
so TypeScript callers can express setting and clearing correctly (locate the
contentChanged property in the type/class declaration and change its type
accordingly).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That wouldn't be an unreasonable type declaration, but it doesn't match how other properties (such as mutableContent are declared

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dwrss, that's a fair point. Keeping contentChanged: boolean is consistent with how mutableContent (and similar properties) are declared, even though the runtime setter accepts 1 as well. The simplified boolean type is a reasonable abstraction for TypeScript callers. I'll withdraw this suggestion.

(^_^) 🐇


✏️ Learnings added
Learnt from: dwrss
Repo: parse-community/node-apn PR: 194
File: index.d.ts:370-373
Timestamp: 2026-04-04T01:53:22.032Z
Learning: In parse-community/node-apn (`index.d.ts`), APS convenience properties like `mutableContent`, `contentAvailable`, and `contentChanged` are intentionally typed as `boolean` even though their runtime setters in `lib/notification/apsProperties.js` also accept `1` (numeric). The simplified `boolean` type is the established pattern and should not be widened to `boolean | 1 | undefined` for consistency.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

@dwrss dwrss force-pushed the add-widgets-to-NotificationPushType branch from d059556 to 29c6a90 Compare April 4, 2026 01:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants