Skip to content

feat: SilentMessageEventHandler - #162

Merged
eduzatoni merged 1 commit into
New-Architecture-and-Expofrom
MV-1188
Sep 10, 2026
Merged

feat: SilentMessageEventHandler#162
eduzatoni merged 1 commit into
New-Architecture-and-Expofrom
MV-1188

Conversation

@biancalui-emarsys

Copy link
Copy Markdown
Contributor

MV-1188

@hyperspace-pr-bot

hyperspace-pr-bot Bot commented Sep 3, 2026

Copy link
Copy Markdown

Control Panel

Hi, I'm an AI-powered Review Bot that helps you with summarizing and reviewing pull requests.
To interact with me, just use the following actions:

  • 📝 Summarize PR
  • 🔍 Review
  • 🗑️ Delete all bot comments and reviews

@hyperspace-pr-bot

Copy link
Copy Markdown

Summary

The following content is AI-generated and provides a summary of the pull request:


Add setSilentMessageEventHandler Support

New Feature

✨ Introduces setSilentMessageEventHandler() — a new API that enables handling silent push notifications both when the app is in the foreground/background (iOS via EventEmitter) and when the app is killed (Android via HeadlessJsTask).

Changes

  • src/wrapper/native/NativeEmarsys.ts: Added onSilentMessageEvent EventEmitter and setSilentMessageEventHandler() to the native module spec.
  • src/wrapper/index.ts: Implemented setSilentMessageEventHandler() with platform-specific routing — Android uses AppRegistry.registerHeadlessTask, iOS uses the native EventEmitter.
  • src/constants.ts: Added SILENT_MESSAGE_EVENT_HEADLESS_TASK_NAME constant ('EmarsysSilentMessageEvent').
  • android/src/main/java/com/emarsys/reactnative/RNEmarsysHeadlessJsTaskService.kt: New Android HeadlessJsTaskService that launches a headless JS task when a silent push is received while the app is not running.
  • android/src/main/AndroidManifest.xml: Registered RNEmarsysHeadlessJsTaskService in the Android manifest.
  • android/src/main/java/com/emarsys/reactnative/utils/EventUtils.kt: Added setSilentMessageEventHandler() with its own silentMessageEventsCache — decoupled from the general event handler. Removed setSilentMessageEventHandler from setEventHandler().
  • android/src/main/java/com/emarsys/reactnative/wrapper/NativeEmarsys.kt: Implemented setSilentMessageEventHandler() bridge method.
  • android/src/main/java/com/emarsys/reactnative/RNEmarsys.kt: Added setSilentMessageEventHandler() call to setup().
  • ios/utils/EventUtils.h / EventUtils.m: Added setSilentMessageEventHandler: method with its own silentMessageEventsCache. Removed silent message handler from setEventHandler:.
  • ios/wrapper/NativeEmarsys.mm: Implemented setSilentMessageEventHandler: bridge method emitting onSilentMessageEvent.
  • ios/RNEmarsys.m: Added setSilentMessageEventHandler:nil call in setup.
  • ios/expo/EmarsysAppDelegateSubscriber.swift / android/.../EmarsysApplicationLifecycleListener.kt: Replaced direct EventUtils.setEventHandler calls with unified RNEmarsys.setup().
  • example/expo/index.ts / example/react-native/index.js: Added module-level setSilentMessageEventHandler registration examples.
  • docs/New-Architecture-and-Expo-framework.md: Added documentation for setSilentMessageEventHandler, fixed import paths from react-native-emarsys-sdk@emartech/react-native-emarsys-sdk.
  • docs/Migration-guide.md: Fixed package name references.
  • __tests__/wrapper/NativeEmarsys.test.ts: Added test cases for setSilentMessageEventHandler.
  • CHANGELOG.md: Added changelog entry for the new method.

  • 🔄 Regenerate and Update Summary
  • ✏️ Insert as PR Description (deletes this comment)
  • 🗑️ Delete comment
PR Bot Information

Version: 1.31.9

  • Event Trigger: issue_comment.edited
  • Summary Prompt: Default Prompt
  • LLM: anthropic--claude-4.6-sonnet
  • Output Template: Default Template
  • Correlation ID: a7ba4fe0-a755-11f1-9fa9-cb65aedd5aed
  • File Content Strategy: Full file content

@hyperspace-pr-bot hyperspace-pr-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The PR introduces silent push notification handling via a HeadlessJsTaskService on Android and an EventEmitter on iOS. While the overall architecture is sound, there are several correctness issues that should be addressed before merging: an inverted/misleading boolean parameter controlling the two handler modes, a missing wake lock acquisition for the Android headless service, potential duplicate event deliveries on iOS due to untracked subscriptions, and a JSONObject.put(key, null) edge case that may silently drop the payload field from the JS task data.

PR Bot Information

Version: 1.31.9

  • Event Trigger: issue_comment.edited
  • Correlation ID: a88b3470-a755-11f1-8d25-9c7ebd29665e
  • File Content Strategy: Full file content
  • LLM: anthropic--claude-4.6-sonnet

Comment thread android/src/main/java/com/emarsys/reactnative/utils/EventUtils.kt Outdated
Comment thread android/src/main/java/com/emarsys/reactnative/utils/EventUtils.kt Outdated
Comment thread src/wrapper/index.ts Outdated
@biancalui-emarsys
biancalui-emarsys force-pushed the MV-1188 branch 3 times, most recently from b0b35d1 to cfe1705 Compare September 3, 2026 09:02

@hyperspace-pr-bot hyperspace-pr-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The iOS EventUtils.m crash on nil payload is in the unchanged portion of the file (not in the diff), so it can't be commented on directly. The RNEmarsys.kt setup() file is also not part of the diff. Only one new comment was successfully posted.

The PR introduces the setSilentMessageEventHandler feature with reasonable structure, but has several issues raised across this and prior review rounds — most notably the unconditional NativeEmarsys.setSilentMessageEventHandler() call outside the platform guard (now flagged), plus the previously flagged wake lock, payload null handling, and duplicate listener concerns that should be addressed before merging.

PR Bot Information

Version: 1.31.9

  • LLM: anthropic--claude-4.6-sonnet
  • Correlation ID: 5642ba70-a797-11f1-8698-4b02017df260
  • Event Trigger: issue_comment.created
  • File Content Strategy: Full file content

Comment thread src/wrapper/index.ts
@hyperspace-pr-bot hyperspace-pr-bot Bot deleted a comment from eduzatoni Sep 3, 2026
@eduzatoni
eduzatoni merged commit 47d0cd3 into New-Architecture-and-Expo Sep 10, 2026
6 checks passed
@eduzatoni
eduzatoni deleted the MV-1188 branch September 10, 2026 07: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.

2 participants