Skip to content
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

[CHNL-15530] Message Bus Support #201

Closed
wants to merge 1 commit into from
Closed

Conversation

dan-peluso
Copy link
Contributor

Description

Mostly logic added to the bridge.js (which I am certainly in support of making a different repo so we can import the same file for every native client we have) to support listening for the bus to be created, and then listening for each of the messages and relaying to the kotlin webview client.

Check List

  • Are you changing anything with the public API?
  • Are your changes backwards compatible with previous SDK Versions?
  • Have you tested this change on real device?
  • Have you added unit test coverage for your changes?
  • Have you verified that your changes are compatible with all Android versions the SDK currently supports?

Changelog / Code Overview

Test Plan

Testing this requires some decent setup:
1 - get app running with onsite modules

2 - get fender running (using this branch) with onsite dependencies as well - should be able to publish a form in the webapp and then make it live

3 - change the HTML code to point to a local :8080 onsite instead of production, and make sure to run the following adb commands if you're running a network proxy
adb reverse tcp:8080 tcp:8080
adb reverse tcp:4001 tcp:4001

You should now be able to see the locally created form from the android test app in the 'messaging' menu. Check the logs after loading and ensure that a inAppFormsDataLoaded has come through.

Related Issues/Tickets

https://klaviyo.atlassian.net/browse/CHNL-15530

const supportedEventTypes = event.detail.eventTypes;
console.log('Supporting message types:', supportedEventTypes);

const messageBus = window['inAppFormsMessageBus']?.messageBus;
Copy link
Contributor

Choose a reason for hiding this comment

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

TIL you can use ? for optional chaining in JS nowadays

Copy link
Contributor

@evan-masseau evan-masseau Jan 2, 2025

Choose a reason for hiding this comment

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

Oof this is annoying, but this syntax may not be supported in an iOS webview on our minimum supported iOS version, ios 13, see
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining#browser_compatibility

@evan-masseau
Copy link
Contributor

@dan-peluso I've created a repo for the bridge js code, and I included the changes you have here. So this PR will get superceded by this one, adding the git submodule with the new repo.

@evan-masseau
Copy link
Contributor

Closing this bc similar code will just live in fender.

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.

4 participants