fix(iam): enable inline media playback in WKWebView for in-app messages#1656
fix(iam): enable inline media playback in WKWebView for in-app messages#1656vitorfinger wants to merge 1 commit into
Conversation
|
@claude review |
There was a problem hiding this comment.
LGTM — two-line WKWebViewConfiguration change to enable inline video playback in in-app messages.
Extended reasoning...
Overview
This PR adds two lines to setupWebviewWithMessageHandler: in OSInAppMessageView.m to configure the WKWebViewConfiguration used for rendering in-app messages: allowsInlineMediaPlayback = YES and mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone. The change addresses an iOS-specific WKWebView default that ignores the HTML playsinline attribute and forces videos into the fullscreen native player.
Security risks
None identified. The change only affects how media is presented within an already-trusted in-app message WebView; it doesn't broaden the content that can be loaded, alter navigation delegation, or change JS message-handler wiring. Autoplay-without-gesture is scoped to the IAM WebView, not the app's other web contexts.
Level of scrutiny
Low. This is a small, mechanical configuration change following documented Apple API behavior, isolated to a single method in the in-app message UI layer. The PR author verified the fix on iOS and confirmed Android behavior was unaffected.
Other factors
Bug hunting found no issues. The mediaTypesRequiringUserActionForPlayback change means IAM video content can auto-play once the user taps, which matches the documented intent and is consistent with how IAMs are triggered (explicit user-driven presentation).
Summary
HTML
<video>elements inside in-app messages always open in fullscreen native player on iOS, even whenplaysinlineattribute is set. This happens becauseWKWebViewConfiguration.allowsInlineMediaPlaybackdefaults toNOon iOS, and it is not being set during WebView initialization inOSInAppMessageView.This PR adds two configuration lines to the
setupWebviewWithMessageHandler:method:Problem
When an in-app message contains a
<video playsinline>tag:This was confirmed to work correctly on Android (where
WebViewallows inline playback by default) but fails on all iOS devices regardless of HTML attributes used (playsinline,webkit-playsinline,x-webkit-airplay="deny", etc.).Root Cause
In
OSInAppMessageView.m, theWKWebViewConfigurationis created without settingallowsInlineMediaPlayback. Per Apple's documentation, this property defaults toNOon iPhone. When it isNO, the HTMLplaysinlineattribute is completely ignored by WKWebView.Changes
allowsInlineMediaPlayback = YESso HTML5 videos can play inline within in-app messagesmediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNoneto allow media playback without requiring additional user interaction beyond the initial tapTesting
Tested with a OneSignal in-app message containing an HTML5 video player: