Skip to content

Mobile app ​

Your store as an app on iOS and Android: the kitloom app signs in, prices its cart, places orders and gets push about them from this site.

kitloom/mobile-apps · admins: kitloom/mobile-apps-filament, kitloom/mobile-apps-nova

Video lessons ​

Recorded in the Filament admin; the Nova admin works the same way.

Your store as an app on iPhone and Android. The kitloom app is one app for every kitloom site: it reads your catalogue from the same addresses as your site (every page answers as JSON), and it asks this module for what a phone needs beyond that — to sign in, to price the cart it keeps, to place an order, to show the account, and to be told by push when an order moves. One admin, one database, three screens: the site, the iPhone, the Android phone.

The app itself is built from your site's name, icon and colours and published under your own Apple and Google accounts (see Getting the app built). This module is the site's side of it. The admin pages are kitloom/mobile-apps-filament or kitloom/mobile-apps-nova: Mobile app → Settings and Devices.

What the owner does ​

Mobile app: the phones it runs on
Mobile app: your store on the phone
  1. Settings → Serve the app. Until it is on, the app's routes answer "not found" and nothing is sent to any phone.
  2. Install links. Where the app is installed from: the App Store and Google Play links once it is listed, or a public TestFlight link and an APK while it is being tried. The app shows them to nobody; your site's theme and the module's banner do.
  3. App Store banner. With the App Store id (the number in the App Store link), Safari on an iPhone offers the app at the top of every page of the site. One meta tag, no script, no cookie.
  4. Push. On, the customer's phone is told when their order is placed and whenever its status changes, in the site's language. Push goes through Expo's push service, which holds the app's Apple and Google credentials; an access token from Expo's dashboard is optional and kept encrypted.
  5. Oldest app version served. An older app is told to update before it goes on. Leave it empty to serve every version.
  6. Downloadable products. Off by default: a downloadable product is bought on the site only, because Apple makes an app sell digital goods through its own purchases. Physical goods and services are paid as on the site.

Devices lists the phones the app runs on — the platform, the app's version, whose it is, when it was last seen. Delete one and it gets no more push.

What the app does on the site ​

  • Signs in with the email or login name and the password, as the site's login form takes them, with the same locks against guessing. A sign-in makes an application password named after the phone ("Ada's iPhone · Green Pantry"), which the phone keeps as its token: it is listed with the user's other application passwords (REST API → Application passwords, and on their profile), and revoking it signs the phone out. An account that signs in with a second factor (kitloom/two-factor) is asked to use the site: the app has no step for the code.
  • Signs up while Account sign-up is on in the shop's settings, and asks for a lost password through the site's own email.
  • Prices its cart. The cart lives on the phone. The site prices it — the lines with their cards, the coupons, the shipping rates for the address, the taxes, the total — and says on each line what cannot be bought (sold out, gone, a download). A signed-in customer's lines are also the ones the site keeps for them, so the phone and the browser share one cart.
  • Places the order as the site's checkout does, with the same fields and checks, as the customer or as a guest while the shop allows it. Cash on delivery and a bank transfer end in the app; an online gateway's page opens in the phone's browser, and the app reads the order back to learn it is paid.
  • Shows the account: the sections every module offers the account page — orders, addresses, downloads, and bookings' appointments once kitloom/bookings is installed. The app names no module; a section installed later is there at once.
  • Asks for the account to be erased. The App Store requires that an app which makes accounts lets the user delete theirs from the app. With kitloom/privacy installed, the app files an erasure request for the user's own email, as the owner files one: the person confirms it from the email, and the owner erases what the law lets go under Tools → Erase Personal Data. Without kitloom/privacy the app shows the site's email instead.

With kitloom/privacy, Tools → Export Personal Data lists the user's devices (never the push token), and Erase Personal Data forgets them.

Getting the app built ​

The app's code is kitloom/app, an Expo (React Native) project. One file, kitloom.json, names the site: npm run configure -- https://your-site.example reads this module's app/v1/site and writes the name, the icon and the colours into it. Then eas build makes the iPhone and Android builds under your own Apple Developer and Google Play accounts, and TestFlight and Google Play's testing tracks hand them to your first testers before the stores list them. Apple lists a store that ships; a demo store is refused.

Routes ​

Under the site's REST root, /wp-json/app/v1/, with WordPress's JSON errors. A phone sends its token as Authorization: Bearer <token>; no session, no CSRF. Every route answers mobile_app_disabled (404) while the app is not served, and mobile_app_update_required (426) to an app older than the minimum (the X-Kitloom-App header names its version).

RouteMethodsWhat
/siteGETThe site's name, icon and logo, language, currency, the shop's pages and rules, the payment methods, the account's sections, the install links, the minimum version, whether push is on
/auth/sign-inPOSTlogin, password, app (the app's name), device (name, platform, app_version, locale, push_token) → token, user
/auth/sign-upPOSTname, email, password, app, device → token, user (404 while sign-up is off)
/auth/meGETThe token's user with their addresses
/auth/sign-outPOSTRevokes the token; push_token frees the phone
/auth/forgot-passwordPOSTlogin — the site's reset email, the same answer whether an account matched or not
/auth/accountDELETEpassword — an erasure request through kitloom/privacy (202), 501 without it
/cart/quotePOSTlines (product_id, quantity, variation_id, variation), coupons, destination, shipping_rate, email → the cart as the site's cart page sees it, plus problems per line
/cart/savedGET, PUTThe signed-in customer's lines kept on the site
/checkoutPOSTlines, coupons and the checkout's fields (billing_*, shipping_*, ship_to_different_address, shipping_method, payment_method, order_comments, createaccount, account_password, terms) → order, payment.url for a gateway, token for an account made here
/orders/{id}GETThe order, the customer's own or a guest's with ?key=
/account/{section}GETA section of the account by key, with its own query (id, list)
/account/details, /account/addressPOSTThe details and an address (type: billing or shipping), as the shop's forms save them
/devicesPUTpush_token, platform, name, app_version, locale — a guest's phone too
/devices/{token}DELETEForgets the phone

The catalogue is not here: a product, a category, a search and the front page are read from their own addresses with Accept: application/json (?include=catalog, productDetails, storefront, menus), as the site's own front end reads them.

Settings ​

OptionDefaultWhat
mobile_app_enabledoffThe app is served
mobile_app_ios_url, mobile_app_android_url, mobile_app_testflight_url, mobile_app_apk_url—Install links
mobile_app_ios_app_id—The App Store id, for the banner
mobile_app_smart_banneroffSafari's App Store banner on the site's pages
mobile_app_min_version—The oldest app version served
mobile_app_push_enabledonPush about orders
mobile_app_expo_token—Expo's access token, encrypted; written by the settings page only
mobile_app_downloadsoffDownloadable products may be bought in the app

Push ​

SendPush is a queued job: the customer's phones are told from the queue, through https://exp.host/--/api/v2/push/send, one ticket per phone. php artisan mobile-apps:push-receipts (scheduled hourly) reads the receipts and forgets the phones Apple and Google no longer know, as Expo asks every sender to. The phones are mobile_devices, the tickets mobile_push_tickets.

Configuration ​

php artisan vendor:publish --tag=kitloom-mobile-apps-config for kitloom-mobile-apps.php: routes.register, push.endpoint and push.timeout, privacy.register, and the admin sections (filament.register, nova.register). The rate limit and the application passwords are kitloom/api's.

Tests ​

From the application that installs the package: php vendor/bin/phpunit --testsuite MobileApps.

Read more ​

kitloom — modules and themes for Laravel.
Contact · Pricing · Services · License · Refunds · Privacy · Community · YouTube · [email protected]