-
Notifications
You must be signed in to change notification settings - Fork 43
[SDK-234] Add real time updates to iOS #803
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
215ddb8
66937c6
9c4326a
f155677
2f480f0
ac42052
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -950,6 +950,12 @@ export class Iterable { | |
| RNEventEmitter.removeAllListeners( | ||
| IterableEventName.handleAuthFailureCalled | ||
| ); | ||
| RNEventEmitter.removeAllListeners( | ||
| IterableEventName.handleEmbeddedMessageUpdateCalled | ||
| ); | ||
| RNEventEmitter.removeAllListeners( | ||
| IterableEventName.handleEmbeddedMessagingDisabledCalled | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -1083,6 +1089,24 @@ export class Iterable { | |
| } | ||
| ); | ||
| } | ||
|
|
||
| if (Iterable.savedConfig.onEmbeddedMessageUpdate) { | ||
| RNEventEmitter.addListener( | ||
| IterableEventName.handleEmbeddedMessageUpdateCalled, | ||
| () => { | ||
| Iterable.savedConfig.onEmbeddedMessageUpdate?.(); | ||
| } | ||
| ); | ||
| } | ||
|
|
||
| if (Iterable.savedConfig.onEmbeddedMessagingDisabled) { | ||
| RNEventEmitter.addListener( | ||
| IterableEventName.handleEmbeddedMessagingDisabledCalled, | ||
| () => { | ||
| Iterable.savedConfig.onEmbeddedMessagingDisabled?.(); | ||
| } | ||
| ); | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if Iterable.savedConfig.embeddedMessagingEnabled ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done! |
||
| } | ||
|
|
||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -339,6 +339,42 @@ export class IterableConfig { | |
| */ | ||
| enableEmbeddedMessaging = false; | ||
|
|
||
| /** | ||
| * A callback function that is called when embedded messages are updated. | ||
| * | ||
| * This callback is triggered when the local cache of embedded messages changes, | ||
| * such as when new messages arrive or existing messages are removed. | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * const config = new IterableConfig(); | ||
| * config.onEmbeddedMessageUpdate = () => { | ||
| * console.log('Embedded messages updated!'); | ||
| * // Refresh your UI to display the latest messages | ||
| * }; | ||
| * Iterable.initialize('<YOUR_API_KEY>', config); | ||
| * ``` | ||
| */ | ||
| onEmbeddedMessageUpdate?: () => void; | ||
|
|
||
| /** | ||
| * A callback function that is called when embedded messaging is disabled. | ||
| * | ||
| * This callback is triggered when embedded messaging becomes unavailable, | ||
| * which can happen due to configuration issues or API errors. | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * const config = new IterableConfig(); | ||
| * config.onEmbeddedMessagingDisabled = () => { | ||
| * console.warn('Embedded messaging has been disabled'); | ||
| * // Hide embedded message UI or show error state | ||
| * }; | ||
| * Iterable.initialize('<YOUR_API_KEY>', config); | ||
| * ``` | ||
| */ | ||
| onEmbeddedMessagingDisabled?: () => void; | ||
|
|
||
| /** | ||
| * Converts the IterableConfig instance to a dictionary object. | ||
| * | ||
|
|
@@ -377,6 +413,21 @@ export class IterableConfig { | |
| */ | ||
| // eslint-disable-next-line eqeqeq | ||
| authHandlerPresent: this.authHandler != undefined, | ||
| /** | ||
| * A boolean indicating if an embedded message update callback is present. | ||
| * | ||
| * TODO: Figure out if this is purposeful | ||
| */ | ||
| // eslint-disable-next-line eqeqeq | ||
| onEmbeddedMessageUpdatePresent: this.onEmbeddedMessageUpdate != undefined, | ||
| /** | ||
| * A boolean indicating if an embedded messaging disabled callback is present. | ||
| * | ||
| * TODO: Figure out if this is purposeful | ||
| */ | ||
| // eslint-disable-next-line eqeqeq | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| onEmbeddedMessagingDisabledPresent: | ||
| this.onEmbeddedMessagingDisabled != undefined, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Comment on lines
+416
to
+430
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These feel unnecessary. |
||
| /** The log level for the SDK. */ | ||
| logLevel: this.logLevel, | ||
| expiringAuthTokenRefreshPeriod: this.expiringAuthTokenRefreshPeriod, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function with high complexity (count = 6): initialize [qlty:function-complexity]