Skip to content

fix(iam): enable inline media playback in WKWebView for in-app messages#1656

Open
vitorfinger wants to merge 1 commit intoOneSignal:mainfrom
vitorfinger:fix/enable-inline-media-playback
Open

fix(iam): enable inline media playback in WKWebView for in-app messages#1656
vitorfinger wants to merge 1 commit intoOneSignal:mainfrom
vitorfinger:fix/enable-inline-media-playback

Conversation

@vitorfinger
Copy link
Copy Markdown

Summary

HTML <video> elements inside in-app messages always open in fullscreen native player on iOS, even when playsinline attribute is set. This happens because WKWebViewConfiguration.allowsInlineMediaPlayback defaults to NO on iOS, and it is not being set during WebView initialization in OSInAppMessageView.

This PR adds two configuration lines to the setupWebviewWithMessageHandler: method:

configuration.allowsInlineMediaPlayback = YES;
configuration.mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;

Problem

When an in-app message contains a <video playsinline> tag:

  1. User taps play
  2. iOS opens the native fullscreen video player on top of the in-app message WebView
  3. A black screen appears while audio plays behind it
  4. The user cannot see the video content

This was confirmed to work correctly on Android (where WebView allows 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, the WKWebViewConfiguration is created without setting allowsInlineMediaPlayback. Per Apple's documentation, this property defaults to NO on iPhone. When it is NO, the HTML playsinline attribute is completely ignored by WKWebView.

Changes

  • Set allowsInlineMediaPlayback = YES so HTML5 videos can play inline within in-app messages
  • Set mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone to allow media playback without requiring additional user interaction beyond the initial tap

Testing

Tested with a OneSignal in-app message containing an HTML5 video player:

  • Before fix (iOS): Video opens fullscreen native player, black screen, audio plays behind
  • After fix (iOS): Video plays inline within the in-app message as expected
  • Android: Already works correctly (no changes needed)

Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

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.

1 participant