Skip to content

Conversation

@lposen
Copy link
Contributor

@lposen lposen commented Jan 11, 2026

🔹 JIRA Ticket(s) if any

✏️ Description

  • Add ability to sync messages
  • Add ability to get messages

Testing

  • Run the setup
  • Login and then click on the "Embedded" tab
  • Click "Sync messages"
    • In the Xcode Console, you should see something that looks like this:
       💛 17:55:06.1810:0x600001836640:ReactIterableAPI:syncEmbeddedMessages():512
       💚 17:55:06.2020:0x600001836640:Pending:init(value:):199
       💚 17:55:06.2050:0x600001836640:Pending:init(value:):199
       💚 17:55:06.7080:0x60000185fc80:Pending:deinit:215
       💚 17:55:06.7090:0x60000185fc80:Pending:deinit:215
      
  • Click "Get messages"
  • If you have embedded messages which are active, you should see the data for them in the emulator.
Screenshot 2026-01-11 at 5 58 10 PM

Setup

  • cd into root and run yarn install
  • cd into example and run yarn install
  • cd into ios and run bundle exec pod install
  • open two separate terminals.
  • In Terminal 1
    • run watchman watch-del-all
    • run yarn start --reset-cache
  • In Terminal 2
    • cd into ios
    • run open ReactNativeSdkExample.xcworkspace
    • Once Xcode opens the project, choose an emulator then click the play button to run it.

@lposen lposen added the embedded Issues/PRs related to Embedded Messages label Jan 11, 2026
@github-actions
Copy link

github-actions bot commented Jan 11, 2026

Lines Statements Branches Functions
Coverage: 62%
62.72% (392/625) 38.64% (97/251) 61.5% (139/226)

@qltysh
Copy link

qltysh bot commented Jan 11, 2026

Qlty

Total Coverage: Coverage tags mismatch: head has [] but base only has []

🚦 See full report on Qlty Cloud »

🛟 Help
  • Diff Coverage: Coverage for added or modified lines of code (excludes deleted files). Learn more.

  • Total Coverage: Coverage for the whole repository, calculated as the sum of all File Coverage. Learn more.

  • File Coverage: Covered Lines divided by Covered Lines plus Missed Lines. (Excludes non-executable lines including blank lines and comments.)

    • Indirect Changes: Changes to File Coverage for files that were not modified in this PR. Learn more.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds the ability to sync embedded messages and retrieve embedded messages with optional placement ID filtering for the iOS platform. The Android implementation already exists in the codebase.

Changes:

  • Added iOS native implementation for syncEmbeddedMessages() and getEmbeddedMessages() methods
  • Added serialization support for IterableEmbeddedMessage to convert to dictionary format
  • Simplified the example app usage to pass placement IDs directly instead of chaining promises

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
ios/RNIterableAPI/Serialization.swift Adds toDict() extension for IterableEmbeddedMessage to serialize messages for React Native
ios/RNIterableAPI/ReactIterableAPI.swift Implements syncEmbeddedMessages() and getEmbeddedMessages() methods with placement ID filtering
ios/RNIterableAPI/RNIterableAPI.mm Exports the new methods for both new and legacy React Native architectures
example/src/components/Embedded/Embedded.tsx Simplifies the getEmbeddedMessages callback to accept placement IDs directly as a parameter

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

public func syncEmbeddedMessages() {
ITBInfo()
IterableAPI.embeddedManager.syncMessages { }
}

Choose a reason for hiding this comment

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

What happens when syncMessages fails.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately, it would swallow it. I would love to add success/error callbacks, but unfortunately Android does not seem to expose them, so I would only be able to do so for iOS. As RN needs to have similar capabilities for both, I kind of have to forgo the error handling here as I can't seem to figure it out properly in Android.

@Ayyanchira -- please let me know if I misunderstood this!

let placementMessages = IterableAPI.embeddedManager.getMessages(
for: placementId.intValue
)
messages.append(contentsOf: placementMessages)

Choose a reason for hiding this comment

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

what if placementMessages is nil

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would return an empty array

ITBInfo()
var messages: [IterableEmbeddedMessage] = []

if let placementIds = placementIds, !placementIds.isEmpty {

Choose a reason for hiding this comment

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

need a comment here to explain why if placementIds is nil or empty we just do IterableAPI.embeddedManager.getMessages(). Would the messages array be coherent in both cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would be coherent for both. Added a comment regarding this, but not 100% sure if this is what you meant. Please let me know if it is not.

// Serialize metadata (which is Codable)
if let metadataDict = SerializationUtil.encodableToDictionary(encodable: metadata) {
dict["metadata"] = metadataDict
}

Choose a reason for hiding this comment

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

What if serialization fails but the metadata is partially encodable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

JSONEnvoder is atomic -- If any property fails to encode, the entire encoding will fail. So there wouldn't be partial encoding. But the entire metadata would be silently omitted.

Updated this so that it would fail if the encoding fails so that the error isn't swallowed.

if let elements = elements,
let elementsDict = SerializationUtil.encodableToDictionary(encodable: elements) {
dict["elements"] = elementsDict
}

Choose a reason for hiding this comment

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

What is serialization fails but the elementsDict is partially encodable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated this -- let me know if this works

Copy link

@sumeruchat sumeruchat left a comment

Choose a reason for hiding this comment

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

LGTM

Base automatically changed from loren/embedded/SDK-240-ios-add-ability-to-start-and-end-a-session to loren/embedded/master January 13, 2026 22:28
@lposen lposen merged commit 05adbaa into loren/embedded/master Jan 13, 2026
7 of 8 checks passed
@lposen lposen deleted the loren/embedded/SDK-235-ios-add-ability-to-sync-and-get-messages branch January 13, 2026 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

embedded Issues/PRs related to Embedded Messages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants