Page MenuHomePhabricator

Launch app if available when browsing Wikipedia on KaiOS device
Open, MediumPublic

Description

Similar to what is done on other mobile platforms, clicking on a Wikipedia link on KaiOS should view the article using the app if available.

Event Timeline

AMuigai triaged this task as Medium priority.Feb 13 2020, 1:46 PM
hueitan edited projects, added Inuka-Team (Kanban); removed Inuka-Team.
hueitan moved this task from Backlog to Ready for Dev on the Inuka-Team (Kanban) board.

I have added the following to manifest according to the developer guide from KaiOS but doesn't work

"redirects": [
  {
    "from": "https://www.wikipedia.org/",
    "to": "/index.html"
  }
]

@hueitan I don't think that's what redirects is for.

From the docs:

The scope of the redirects declared by redirects is limited to the app that declares them. That makes it so that several apps can redirect the same public URL to their own local resources, and it also prevents global hijacking of public URLs by an application.

Global hijacking is actually what we are trying to do.

The way to do it is with activities.

The web site needs to trigger the activity

new MozActivity({type: 'wikipedia', title: 'Cat'})

The application manifest needs to include it

"activities": {
    "wikipedia": {
      "href": "/index.html",
      "returnValue": false
    }
  }

The app needs to register a handler

navigator.mozSetMessageHandler('activity', function(activityRequest) {
  const option = activityRequest.source;
  if (option.name === "wikipedia") {
    route(option.title)
  }
});

That's the only way I could find to make it work.

As mentioned above, the key to make it work is to have a script (or a few additional lines of code in an existing script) in Wikipedia to trigger the activity. Since we don't vary the cache by user agent, this means sending irrelevant code to a lot of clients.

We would like to explore if this can be achieved in a way acceptable to all parties. Pinging @phuedx for Readers-Web-Backlog and @Krinkle to start the conversation.

I don't have an immediate answer on the perf impact of doing this client-side. At glance, it does seem worrying that one would have to fully load the mobile site in the KaiOS browser on and then be taken away to the app where it then boots and loads the same page again. That could be a non-start in terms of performance, especially considering how resource-constrained KaiOS devices generally are. That's irrespective of the impact on other users of the mobile site.

Where does this sit in terms of priority? Is this something we can tackle sometime after a successful launch? It might be risky to do that in one go.

Maybe KaiOS app could simply be also hosted on .wikipedia.org and just presented there in a similar way the mobile interface is?

While this is important to support, I'm (re)moving this task from the first launch.

It'll sit in our ideas board, as we determine how this can be supported either on the KaiOS side, or, how we can prevent it from having negative impact on performance.