Created
September 22, 2017 00:33
Swift bridge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) { | |
guard let type = EmbeddedAppMessageType(rawValue: message.name) else { return } | |
switch type { | |
case .setTitle: | |
let title = message.body as? String | |
setTitle(title: title) | |
case .loadingOn: | |
startActivityIndicator(start: true) | |
case .loadingOff: | |
startActivityIndicator(start: false) | |
case .setPrimaryButton: | |
guard let payload = [message.body] as? [[String: Any]] else { | |
setPrimaryButton(button: nil) | |
return | |
} | |
let primaryButton: EmbeddedAppButton? = EmbeddedAppButton.create(payload: payload).first | |
setPrimaryButton(button: primaryButton) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment