Mobile Development 13 min read

Cross-Platform Receipt Printing Solution for Retail Applications

The article outlines a cross‑platform receipt‑printing solution for retail apps that uses JavaScript‑based parsing, server‑editable templates, and native JS engines on iOS and Android to dynamically manage diverse printer models, reduce maintenance, and enable fast template updates across iOS, Android, and web.

Youzan Coder
Youzan Coder
Youzan Coder
Cross-Platform Receipt Printing Solution for Retail Applications

This article presents a comprehensive technical solution for receipt printing in retail software, addressing the challenges of multi-platform consistency and dynamic updates.

Background and Pain Points: In retail business operations, receipt printing is essential for every customer transaction. The main pain points included: (1) each platform (iOS, Android, Web) implemented separate printing workflows, requiring modifications across all three platforms and relying on app releases for updates; (2) different business scenarios had inconsistent template implementations and printing logic, increasing maintenance costs; (3) adapting to various receipt printer devices required separate implementation for each platform.

Solution Architecture: The solution implements a cross-platform approach involving frontend, mobile, and server components. The core design uses JavaScript for cross-platform receipt parsing scripts with dynamic update capabilities, server-side editable style templates for flexible content customization, and client-side JS executor engines for printer device connection management.

JS Engine Design: The engine handles template and business data processing, integrating business data into templates and converting them to print instructions. It uses HandleBars.js for template compilation and supports multiple content types (text, images, QR codes, barcodes). The engine adapts to different printer models (365wifi, sunmi, sprt80, sprt58, wangpos, aclas, xprinter) through instruction set parsing.

Template Management Service: Provides dynamic template editing and distribution, storing template configuration and business templates. The service offers interfaces for mobile clients to fetch dynamic configuration and business receipt templates.

Mobile Implementation: iOS uses JavaScriptCore framework while Android uses J2V8 for JS execution. The mobile client handles dynamic template configuration, printing workflow orchestration, image processing (download, compression, binarization, hex conversion), and multi-print functionality using dispatch semaphores for sequential printing.

Caching Strategy: Implements local file caching for templates (allowing slight delay) and memory caching for business data linked to the printing page, reducing API calls on subsequent prints.

mobile developmentcross-platformiosAndroidJavaScript enginereceipt printingprinter adaptationtemplate management
Youzan Coder
Written by

Youzan Coder

Official Youzan tech channel, delivering technical insights and occasional daily updates from the Youzan tech team.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.