Page MenuHomePhabricator

mobile-html interaction handling
Closed, ResolvedPublic

Description

Background

Apps need to know information about any user interaction on the mobile-html article page so it can respond appropriately

How

Add setInteractionHandler(interactionHandler) to the JS bridge

interactionHandler would be a function that takes a dictionary with a required action property that indicates what action was taken. Any other properties are the user information for that action. For example, tapping a link would produce {action: "link", href: "/wiki/otherpage"}. Other examples would be {action: "edit_section", section_id: 0} and {action: "reference", reference_id: "id2", adjacent_reference_ids: ["id1", "id2", "id3"]}.

When the user interacts with the page, the interactionHandler is called with the appropriate information.

Event Timeline

@bearND this handles what's in both of those files as well as some new functionality. I don't think either approach should be directly re-used since there's platform-specific js-to-native bridging in each. Instead, the each app's native code calls into js to register the interactionHandler with the appropriate message handler.

On iOS the app would call:
wmf.setInteractionHandler((interaction) => { window.webkit.messageHandlers.interaction.postMessage(interaction); });

On Android (assuming there will be a new JavascriptInterface called InteractionWebInterface that could be used directly) the app would call:
wmf.setInteractionHandler((interaction) => { window.InteractionWebInterface.post(interaction); });

Mentioned in SAL (#wikimedia-operations) [2019-07-02T17:43:34Z] <bsitzmann@deploy1001> Started deploy [mobileapps/deploy@9ca9b0f]: Update mobileapps to 941e14f (T219998 T217352 T219909)

Mentioned in SAL (#wikimedia-operations) [2019-07-02T17:49:24Z] <bsitzmann@deploy1001> Finished deploy [mobileapps/deploy@9ca9b0f]: Update mobileapps to 941e14f (T219998 T217352 T219909) (duration: 05m 49s)