skip to content

In a second-hand marketplace mobile app, what back stack should a shared listing link build on a cold start, and who builds it?

level: middleimportance: must knowfreq 50%

answer

  1. nothing to go back to
  2. as if the user had browsed there
  3. start destination underneath
  4. one resolver for every entry
  5. cold and warm, same function

basics

~20 s

A synthetic stack that matches one the user could have navigated: the start destination, any parent screen the listing lives under, then the listing on top. One app-level entry-point resolver builds it from the URL, never the listing screen itself.

solid answer

~50 s

On a cold start the process is new, so there is no stack at all: the link is the only thing the app knows. The OS hands the URL over at launch, and an **entry-point resolver** owned by the app shell parses and validates it into a route, then expands that route into a **synthetic back stack**, for example `[browse, listing(123)]`. The rule is that the stack must be realistic: one the user could have built by tapping through the app, so the app's own back or up affordance walks to the browse feed instead of leaving. The resolver replaces the stack in one step. A malformed link becomes the start destination; a listing sold an hour ago still opens, and its screen shows the sold state. When the app is already running, the OS delivers the link on a second path; send it through the same resolver and choose the warm-start policy deliberately.

code

pseudocode · 10 lines
pseudocode
function stackFor(url):
  route = parseRoute(url)          // checks host, path and ID format
  if route == null:
    return [browse()]              // malformed or unknown: start destination
  if route.kind == "listing":
    return [browse(), listing(route.listingId)]
  return [browse()]

function onLinkReceived(url):      // called on cold launch and while running
  navigator.replaceStack(stackFor(url))

go deeper

for a junior

Remember that a cold start has no history, so the app must build one: the start destination underneath and the linked listing on top.

for a middle

Explain the resolver's three steps, parse, validate, expand, and why both the launch-time and the running-app delivery paths must call the same code.

for a senior

Show judgement on the warm start: when to replace, when to push, how to protect a flow with unsaved input, and how a sold or malformed link degrades.

for a principal

Treat entry-point behaviour as a product rule the whole app follows, with one owner, so new features inherit correct links instead of each team inventing its own.

## Cold start: nothing to go back to A **cold start** is a launch where the app's process is not running, so nothing is in memory: no screens, no history. When a user taps a shared listing link in a message and the app opens cold, the link is the only information the app has. If the app simply opens the listing as the only screen, the user is stranded: the app's back affordance has nowhere to go, and the start destination they would normally reach is not there. The fix is a **synthetic back stack**: a stack the app constructs to look as if the user had navigated there by hand. One platform's own navigation guidance states the principle directly: deep linking should simulate manual navigation, the start destination is added beneath the target, and the synthetic stack must be one that could have been reached organically. ## What a valid synthetic stack is For a second-hand marketplace app, a listing link should produce something like: - **bottom**: the start destination, the browse feed; - **middle**: any parent the app's structure always puts above it, such as a category screen, only if normal navigation would always pass through it; - **top**: `listing(123)`. The stack should be **simple**: start destination plus the target, plus the root of any section that contains the target. Inventing a long history the user never had, such as a search results page for a query they never typed, is not realistic and confuses back. On one platform, if the link was opened from inside another app, the system back control can return the user to that other app while the in-app up affordance walks the synthetic stack. The app does not fight that; its job is that its *own* navigation leads through the listing's parents to the start destination. ## Who builds it | Candidate builder | Problem | |---|---| | The listing screen, adding parents when it finds itself alone | Every screen re-implements the rule; notification taps and sign-in resumes get different results | | The operating system | It knows nothing about the app's screens; it only delivers the URL | | The web page behind the link, passing a stack as a parameter | External input dictates internal structure and ties the website to app internals | | **One entry-point resolver in the app shell** | One place parses, validates and expands every entry point | The resolver lives with whatever owns the app's navigation graph, usually the app shell that composes the feature modules. It does three things in order: **parse** the URL into a route, **validate** it (known path, well-formed ID), and **expand** it into a full stack, which the navigation layer installs in one replace operation. ## Cold versus warm delivery The OS delivers a link on two paths: at launch when the app is not running, and to the live app when it is running or suspended. Both must call the same resolver, or the two paths drift apart, which is how an app ends up correct on a cold start and wrong on a warm one. On a **warm start** a stack already exists, so there is a policy to choose: 1. **Replace** the stack with the synthetic one. One platform's guidance does exactly this when a link targets the app. 2. **Push** the listing onto the current section when that does not interrupt anything. 3. **Protect a flow in progress**: if the user is halfway through an offer form with unsaved input, do not silently destroy it; push the listing above it, or ask first. What is *not* a policy is pushing the link on top of whatever happens to be showing, so that back from the listing lands in yesterday's half-finished checkout. ## When the target is gone or malformed Links outlive what they point to. A listing shared last week may be sold. The route is still valid, because validity is about the format of the link, not the state of the data, so the stack is built normally and the listing screen shows the sold state, perhaps with similar items. A link whose parameters are **malformed** is different: one platform's guidance says to validate every URL parameter and discard malformed links, so the resolver falls back to the start destination rather than handing bad input to a screen. A link should also only *open* things. It should never directly delete content or reveal sensitive information, because anyone can craft a URL; actions happen on a screen the user confirms.

  • The app is open on a half-filled offer form when a listing link arrives; what should happen?
    That is a warm start, and the policy must be explicit. Replacing the stack, as one platform's guidance does, would silently throw away the user's input; pushing on top of whatever is showing can bury the form under unrelated screens. A common rule is to replace when nothing is in progress and, when a flow holds unsaved input, push the listing above it or ask first. Either way the same resolver builds the target.
  • The listing in the link was sold an hour ago; what stack does the app build?
    The same one: browse feed underneath, listing on top. The link is well-formed, so the route is valid; whether the item is still for sale is data, not navigation. The listing screen loads the current state, shows that it is sold, and can offer similar items. Dumping the user on the feed with no explanation, or showing a blank error screen, wastes the visit.
  • Why not let the listing screen add the browse feed beneath itself when it finds it is the only screen?
    Because then every screen owns a copy of the rule, and each entry point gets a slightly different answer. The screen also renders before its parents exist, which can flash or break transitions. Building the stack once, in the resolver, before anything is shown keeps links, notification taps and sign-in resumes consistent.

  • Open the listing as the only screen; back just closes the app.
  • The operating system works out the listing's parent screens from the link by itself.
  • A warm-start link should always be pushed on top of whatever is showing.
  • Each screen should notice it is first and add its own parents.
  • Malformed link parameters can go straight to the screen, which will cope.
  • A link to a sold listing should be treated as an invalid route.