IWithDeepLinking.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright (c) 2024 Vuplex Inc. All rights reserved.
  2. //
  3. // Licensed under the Vuplex Commercial Software Library License, you may
  4. // not use this file except in compliance with the License. You may obtain
  5. // a copy of the License at
  6. //
  7. // https://vuplex.com/commercial-library-license
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. namespace Vuplex.WebView {
  15. /// <summary>
  16. /// An interface implemented by a webview if it supports [deep linking](https://en.wikipedia.org/wiki/Mobile_deep_linking).
  17. /// </summary>
  18. /// <remarks>
  19. /// On iOS, in order to open a link with a custom URI scheme, that scheme must also be listed in
  20. /// the app's Info.plist using the key [LSApplicationQueriesSchemes](https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/LaunchServicesKeys.html),
  21. /// otherwise iOS will block the custom URI scheme from being loaded.
  22. /// Example Info.plist entry:
  23. /// <code>
  24. /// &lt;key&gt;LSApplicationQueriesSchemes&lt;/key&gt;
  25. /// &lt;array&gt;
  26. /// &lt;string&gt;vnd.youtube&lt;/string&gt;
  27. /// &lt;/array&gt;
  28. /// </code>
  29. /// </remarks>
  30. /// On Android, deep linking is only triggered by a URL with a custom scheme (e.g. my-app://path).
  31. /// A URL with an http:// or https:// scheme will always open the web page in the browser rather than deep link to an external app.
  32. /// <remarks>
  33. /// </remarks>
  34. /// <example>
  35. /// <code>
  36. /// await webViewPrefab.WaitUntilInitialized();
  37. /// var webViewWithDeepLinking = webViewPrefab.WebView as IWithDeepLinking;
  38. /// if (webViewWithDeepLinking == null) {
  39. /// Debug.Log("This 3D WebView plugin doesn't support IWithDeepLinking: " + webViewPrefab.WebView.PluginType);
  40. /// return;
  41. /// }
  42. /// webViewWithDeepLinking.SetDeepLinkingEnabled(true);
  43. /// // Load a page with a link that opens the YouTube app.
  44. /// webViewPrefab.WebView.LoadHtml("&lt;a href='vnd.youtube://grP0iDrSjso'&gt;Click to launch YouTube&lt;/a&gt;");
  45. /// </code>
  46. /// </example>
  47. public interface IWithDeepLinking {
  48. /// <summary>
  49. /// Sets whether deep links are enabled. The default is `false`.
  50. /// </summary>
  51. void SetDeepLinkingEnabled(bool enabled);
  52. }
  53. }