feat(stage-capacitor): add notification capability, and a devtool#855
feat(stage-capacitor): add notification capability, and a devtool#855nekomeowww merged 2 commits intomainfrom
Conversation
Summary of ChangesHello @LemonNekoGH, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces the ability for the Capacitor application to utilize local notifications. It sets up the necessary plugin dependencies, provides a dedicated developer tool for testing notification functionality, and ensures that the application's build configurations are aligned with the new feature. This enhancement lays the groundwork for future features that might require user engagement through local alerts. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
⏳ Approval required for deploying to Cloudflare Workers (Preview) for stage-web.
Hey, @nekomeowww, @sumimakito, @luoling8192, @LemonNekoGH, kindly take some time to review and approve this deployment when you are available. Thank you! 🙏 |
There was a problem hiding this comment.
Code Review
This pull request adds notification capabilities to the Capacitor application, including the necessary dependencies for iOS and a new devtools page for testing. The changes are generally good, but I've identified a few areas for improvement regarding the robustness and maintainability of the implementation. My main concerns are a fragile dependency path in the iOS project configuration, a logic issue in handling notification permissions, and the method for generating notification IDs. Please see my detailed comments for suggestions.
| if (permission.display !== 'granted') { | ||
| await LocalNotifications.requestPermissions() | ||
| } |
There was a problem hiding this comment.
The code requests notification permissions if not already granted, but it doesn't check the result of the requestPermissions() call. If the user denies the permission in the prompt, the code will still attempt to schedule a notification, which will fail. You should check the result of the permission request and only proceed if permission is granted.
if (permission.display !== 'granted') {
const permissionResult = await LocalNotifications.requestPermissions()
if (permissionResult.display !== 'granted') {
return toast.error('Notification permission was not granted.')
}
}
| await LocalNotifications.schedule({ | ||
| notifications: [ | ||
| { | ||
| id: Math.floor(Math.random() * 1000000), |
There was a problem hiding this comment.
Using Math.random() for notification IDs is not ideal as it doesn't guarantee uniqueness, which could lead to notifications overwriting each other if they happen to get the same ID. While collisions are unlikely in a development tool, it's a good practice to use a more reliable method for generating unique IDs. A simple and more robust alternative is to use a timestamp.
id: Date.now(),
No description provided.