@@ -1360,6 +1360,8 @@ pub(crate) struct PlatformSpecificWebViewAttributes {
1360
1360
allow_link_preview : bool ,
1361
1361
#[ cfg( target_os = "ios" ) ]
1362
1362
input_accessory_view_builder : Option < Box < InputAccessoryViewBuilder > > ,
1363
+ #[ cfg( target_os = "ios" ) ]
1364
+ limit_navigations_to_app_bound_domains : bool ,
1363
1365
}
1364
1366
1365
1367
#[ cfg( any( target_os = "macos" , target_os = "ios" ) ) ]
@@ -1372,6 +1374,8 @@ impl Default for PlatformSpecificWebViewAttributes {
1372
1374
allow_link_preview : true ,
1373
1375
#[ cfg( target_os = "ios" ) ]
1374
1376
input_accessory_view_builder : None ,
1377
+ #[ cfg( target_os = "ios" ) ]
1378
+ limit_navigations_to_app_bound_domains : false ,
1375
1379
}
1376
1380
}
1377
1381
}
@@ -1432,6 +1436,30 @@ pub trait WebViewBuilderExtIos {
1432
1436
self ,
1433
1437
builder : F ,
1434
1438
) -> Self ;
1439
+ /// Whether to limit navigations to App-Bound Domains. This is necessary
1440
+ /// to enable Service Workers on iOS.
1441
+ ///
1442
+ /// Note: If you set limit_navigations to true
1443
+ /// make sure to add the following to Info.plist in the iOS project:
1444
+ /// ```xml
1445
+ /// <plist>
1446
+ /// <dict>
1447
+ /// <key>WKAppBoundDomains</key>
1448
+ /// <array>
1449
+ /// <string>localhost</string>
1450
+ /// </array>
1451
+ /// </dict>
1452
+ /// </plist>
1453
+ /// ```
1454
+ /// You should also add any additional domains which your app requests assets from.
1455
+ /// Assets served through custom protocols like Tauri's IPC are added to the
1456
+ /// list automatically. Available on iOS only.
1457
+ ///
1458
+ /// Default is false.
1459
+ ///
1460
+ /// See https://webkit.org/blog/10882/app-bound-domains/ and
1461
+ /// https://developer.apple.com/documentation/webkit/wkwebviewconfiguration/limitsnavigationstoappbounddomains
1462
+ fn with_limit_navigations_to_app_bound_domains ( self , limit_navigations : bool ) -> Self ;
1435
1463
}
1436
1464
1437
1465
#[ cfg( target_os = "ios" ) ]
@@ -1448,6 +1476,12 @@ impl WebViewBuilderExtIos for WebViewBuilder<'_> {
1448
1476
. replace ( Box :: new ( builder) ) ;
1449
1477
self
1450
1478
}
1479
+ fn with_limit_navigations_to_app_bound_domains ( mut self , limit_navigations : bool ) -> Self {
1480
+ self
1481
+ . platform_specific
1482
+ . limit_navigations_to_app_bound_domains = limit_navigations;
1483
+ self
1484
+ }
1451
1485
}
1452
1486
1453
1487
#[ cfg( windows) ]
0 commit comments