Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating App Shortcuts on any OS. #35

Open
frank-dspeed opened this issue Aug 16, 2021 · 0 comments
Open

Creating App Shortcuts on any OS. #35

frank-dspeed opened this issue Aug 16, 2021 · 0 comments

Comments

@frank-dspeed
Copy link
Member

Internal prerequired Knowleg

Browsers in general can render data urls

data:text/html;base64,PGgxPkZyYW5rIExlbWFuc2NoaWsgU2hvd2VkIFlvdSBUaGlzPC9oMT4

baste that into your browser you will get

<h1>Frank Lemanschik Showed You This</h1>

wrapped inside a standard conform Dom representation created via the aaopen Rendering algo

Browsers got PWA Shortcut Support for https urls

we can trigger it via scripts inside our data urls

Apple example page

<html>
<head>
  <title>Apple Page</title>
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="#ffffff">
  <meta name="apple-mobile-web-app-title" content="Apple Page">
</head>
  <body>
    <a id="redirect" href="https://apple.com/"></a>
  </body>
</html>
<script type="text/javascript">
  if (window.navigator.standalone) {
    var element = document.getElementById('redirect');
    var event = document.createEvent('MouseEvents');
    event.initEvent('click', true, true, document.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
    setTimeout(function() { element.dispatchEvent(event); }, 25);
  } else {
    var p = document.createElement('p');
    var node = document.createTextNode('SwiftRocks!');
    p.appendChild(node);
    document.body.appendChild(p);
  }
</script>

Try it out! Open this in Safari, press the Share button, add it to your home screen and touch it to see how it works. For a real example, change the link to a deeplink to your app and encode it to base64 to see it in action.

If you try to open a data: page from Swift using open(url), will not work, SFSafariViewController will crash stating that it doesn't understand the URL.

Solution? Run a Local Webserver For Android a Own WebServer is also needed not to open data urls but other additional features

Interristing Reads

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

No branches or pull requests

1 participant