Skip to content

Conversation

@mimosa-ai-bot
Copy link

@mimosa-ai-bot mimosa-ai-bot bot commented Nov 27, 2025

Summary

Implements iOS Screen Time detection for Flutter webviews by exposing the isBlockedByScreenTime property from WKWebView (iOS 26.0+).

This allows applications to detect when a webview is blocked by Screen Time restrictions and provide user-friendly messaging instead of showing an infinite loader.

Linear Ticket: PRO-2378

Changes Made

Files Modified (7 total)

Pigeon API Definition:

  • packages/webview_flutter/webview_flutter_wkwebview/pigeons/web_kit.dart - Added getIsBlockedByScreenTime() method to UIViewWKWebView class

Auto-generated Platform Code:

  • packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/web_kit.g.dart - Generated Dart bindings
  • packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/WebKitLibrary.g.swift - Generated Swift bindings

Native Implementation:

  • packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/WebViewProxyAPIDelegate.swift - Implemented native method with iOS 26.0+ availability check

Dart API:

  • packages/webview_flutter/webview_flutter_wkwebview/lib/src/webkit_webview_controller.dart - Added public isBlockedByScreenTime getter with error handling

Documentation:

  • packages/webview_flutter/webview_flutter_wkwebview/CHANGELOG.md - Added changelog entry

Implementation Details

iOS Version Handling

  • iOS 26.0+: Returns actual isBlockedByScreenTime value from WKWebView
  • iOS < 26.0: Returns false gracefully (no crash or error to user)
  • Uses Swift #available(iOS 26.0, *) for runtime version checking

Usage Example

import 'package:webview_flutter_wkwebview/webview_flutter_wkwebview.dart';

// Check if controller is WebKit and check Screen Time status
if (controller is WebKitWebViewController) {
  final isBlocked = await controller.isBlockedByScreenTime;
  if (isBlocked) {
    // Show user-friendly message instead of infinite loader
    showDialog(
      context: context,
      builder: (context) => AlertDialog(
        title: Text('Content Restricted'),
        content: Text('This content is blocked by Screen Time restrictions.'),
      ),
    );
  }
}

Acceptance Criteria Status

  • ✅ Property accessible on WebKitWebViewController via public getter
  • ✅ iOS 26+ requirement handled with runtime version check
  • ✅ Platform-specific check works (property only on WebKitWebViewController, not base class)
  • ✅ Returns boolean for Screen Time blocking status
  • ✅ Handles older iOS versions gracefully (returns false on iOS < 26.0)

Testing

Recommended Manual Testing

  1. iOS 26.0+ with Screen Time enabled: Verify returns true when webview is blocked
  2. iOS 26.0+ with Screen Time disabled: Verify returns false
  3. iOS < 26.0: Verify returns false without crashing

Integration

  • Follows existing patterns in flutter_packages repository
  • Compatible with current Pigeon version (26.1.2)
  • No breaking changes to existing API

Next Steps: This PR is ready for code review. Once approved and merged, the Linear ticket can be closed.

🤖 Generated with Claude Code

Add getIsBlockedByScreenTime() method to UIViewWKWebView Pigeon interface
and regenerate platform code. This exposes the iOS 26.0+ WKWebView property
for detecting Screen Time blocking.

Related to PRO-2378

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Add getIsBlockedByScreenTime implementation in WebViewProxyAPIDelegate.swift
with iOS 26.0+ availability check using #available. Throws PlatformException
on older iOS versions.

Related to PRO-2378

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Expose Screen Time blocking detection as a public getter on
WebKitWebViewController. Returns false on iOS < 26.0 instead of throwing,
providing graceful degradation for older iOS versions.

Related to PRO-2378

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Add CHANGELOG entry documenting the new isBlockedByScreenTime getter
for iOS 26.0+ Screen Time blocking detection.

Related to PRO-2378

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants