Skip to content

[SDK-363] Expose register device token#877

Open
jferrao-itrbl wants to merge 4 commits into
masterfrom
feature/SDK-363-expose-register-device-token
Open

[SDK-363] Expose register device token#877
jferrao-itrbl wants to merge 4 commits into
masterfrom
feature/SDK-363-expose-register-device-token

Conversation

@jferrao-itrbl

@jferrao-itrbl jferrao-itrbl commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

🔹 JIRA Ticket(s) if any

✏️ Description

Expose registerDeviceToken in React Native bridge:

  • Add Iterable.registerDeviceToken(token) public API
  • Add bridge proxy IterableApi.registerDeviceToken(token)
  • Add TurboModule spec entry in NativeRNIterableAPI.ts
  • Add iOS Swift/Obj-C++ glue with hex-to-Data conversion for APNS tokens
  • Add Android impl + old/new architecture stubs for direct FCM token pass-through
  • Update MockRNIterableAPI and unit tests
  • Add CHANGELOG entry under Unreleased

jferrao-itrbl and others added 4 commits June 12, 2026 09:16
- Add Iterable.registerDeviceToken(token) public API

- Add IterableApi.registerDeviceToken bridge proxy

- Add TurboModule spec entry in NativeRNIterableAPI.ts

- Add iOS Swift/Obj-C++ glue with hex-to-Data conversion for APNS tokens

- Add Android impl + old/new architecture stubs for FCM token pass-through

- Update MockRNIterableAPI and unit tests

- Add CHANGELOG entry under Unreleased
@github-actions

Copy link
Copy Markdown
Lines Statements Branches Functions
Coverage: 68%
68.95% (522/757) 56.11% (202/360) 65.09% (166/255)

@qltysh

qltysh Bot commented Jun 19, 2026

Copy link
Copy Markdown

Qlty


⚠️ Comments skipped @jferrao-itrbl doesn't have a Qlty seat in Iterable.

Qlty doesn't post analysis or coverage comments for contributors without a seat. An authorized user can grant @jferrao-itrbl a seat from this pull request's page in Qlty.

@joaodordio joaodordio self-requested a review June 19, 2026 13:30
@jferrao-itrbl jferrao-itrbl changed the title [DRAFT SDK-363] Expose register device token [SDK-363] Expose register device token Jun 24, 2026
@jferrao-itrbl jferrao-itrbl marked this pull request as ready for review June 24, 2026 16:06

@joaodordio joaodordio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Left some comments on the data(fromHex:) method that could cause regressions, but those are simple changes!

Suggestion:

private func data(fromHex hex: String) -> Data? {
  guard !hex.isEmpty, hex.count.isMultiple(of: 2) else { return nil }
  var data = Data(capacity: hex.count / 2)
  var chars = hex.makeIterator()
  while let high = chars.next(), let low = chars.next() {
    guard let highValue = high.hexDigitValue, let lowValue = low.hexDigitValue else {
      return nil
    }
    data.append(UInt8(highValue << 4 | lowValue))
  }
  return data
}

Everything else looks good! Nice work!


private let inboxSessionManager = InboxSessionManager()

private func data(fromHex hex: String) -> Data? {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

data(fromHex:) returns a non-nil empty Data for empty input, so registerDeviceToken("") falls through and calls IterableAPI.register(token: Data()). That registers an empty APNS token with no error surfaced. Add an hex.isEmpty guard at the top of data(fromHex:) (or in registerDeviceToken before the call) and log the same ITBError so callers see something in their logs.

@objc(registerDeviceToken:)
public func registerDeviceToken(token: String) {
ITBInfo()
guard let tokenData = data(fromHex: token) else {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

if the token is empty, data(fromHex:) will not fail here because it returns an empty Data().

var data = Data()
var chars = hex.makeIterator()
while let high = chars.next(), let low = chars.next() {
guard let highValue = high.hexDigitValue, let lowValue = low.hexDigitValue else {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

NIT: Odd-length input gets silently truncated. The last hex char is consumed by high and the loop exits on low == nil, so we return a token shorter than the source with no error. APNS tokens are always even length, but customers paste tokens from unpredictable places and a malformed input should fail loudly. Reject inputs whose count isn't a multiple of 2 (return nil) so the existing ITBError branch fires.

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