Digital Signage iPhones

For the last few years I've been responsible for a number of Public Information Display Systems (PIDS) or Digital Signage largely based around the venerable Raspberry Pi which hugely reduced the cost of deploying these.

Every one is effectively just displaying a web page. I understand XHTML/CSS/JS better than I do Qt or SwiftUI etc so it made sense to use technologies I was familiar with. That said, the 'web page' is more of an app typically using content streamed by WebSockets, or extensive use of XHR requests.

More recently, I've built some that are a little more processor intensive including a realtime animated map showing aircraft in flight at my local flying school, and an animated departure board there also which mimics the old Solari split-flap display using the excellent Flapper library

These put considerably more load on the Raspberry Pi (probably in part due to my inefficient code) and the map in particular made a lot of writes to the SD card. With it being switched on and off regularly, this resulted in it failing more than once.

The forgotten device in my pocket

What I hadn't thought about, is the iPhone runs these perfectly. Indeed I often used it for testing when developing them (it has the right aspect ratio and effectively acts as a tiny monitor next to my workstation showing the project - in the case of the portrait layout departure board it was easy to flip on its side too!)

Also my iPhone 12 is pricey, and defeats the purpose of a 'low cost' solution. But the optimum device (for my projects anwyay) seemed to be the iPhone 7. I managed to pick up a few broken ones on eBay for about £40-50 (damaged screen, broken speaker etc.. none of which matters for this application)

Single App Mode

Apple (relatively recently) introduced a single app mode to the iPhone. When enabled it locks the iPhone (or iPad) to that app. You can't access any other applications (or even the home screen) and if you reboot the iPhone it will boot straight into the one app you have specified.

Initially I'd hoped I could use this to lock a Safari WebClip in this mode, but that doesn't work. It must be a native application.

The worlds most basic app?

I created a very simple app in Xcode. I don't speak Swift at all, this is entriely based on copy/paste from a demonstration I found, but it works great.

//  ViewController.swift

import UIKit
import WebKit

class ViewController: UIViewController, WKNavigationDelegate {
    var webView: WKWebView!
    
    override func loadView() {
        webView = WKWebView()
        webView.navigationDelegate = self
        view = webView
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        var requrl = "http://example.com/display/&u=";
        if let uuid = UIDevice.current.identifierForVendor?.uuidString {
            requrl += uuid
        }
        let url = URL(string: requrl)!;
        webView.load(URLRequest(url: url))
        webView.allowsBackForwardNavigationGestures = false
    }
}
Note we are intentionally using http:// not https:// here, that's explained later!

Xcode additionally makes it easy to lock the display to Landscape orientation (handy because otherwise the iPhone needs to be kept the right way up or the display will rotate even on the external monitor) and to disable the status bar.

You need a free Apple Developer account to build this app and run it on the iPhone, but when done you'll have an app that does nothing other than load your webpage fullscreen with none of the user browser elements.

Bigger Displays

The right way to connect an iPhone to a TV is, of course, Apple's Digital AV Adapter but at £49 it cost more than I paid for the broken iPhones I'm using. Instead I used this unbranded clone for £9

These third party HDMI interfaces present to the iPhone as a 'computer' and as such you must trust it before enabling Single App Mode (as otherwise you won't see the prompt) - once trusted the iPhone screen will appear on the external monitor / TV within a few seconds and a blue bar persists at the top of the iPhone screen (don't worry, this disappears when you enter Single App Mode)

Securing the iPhone

Locking down the iPhone is easy with the new Apple Configurator 2 tool.

You can restrict as much or as little as you like but I disabled everything except the following (as far as I can tell, those in bold are required)

  • Allow screenshots and screen recording
  • Allow AirPlay and Screen Sharing
  • Allow automatic updates to certificate trust settings
  • Allow trusting new enterprise app authors
  • Allow installing configuration profiles
  • Force Wi-Fi power on
  • Allow USB accessories while device is locked
  • Allow pairing with non-Configurator hosts

I limited the apps to only my own bundle (e.g. com.example.your-display-project-name-here) which, when you apply the profile, effectively hides every other app.

In theory, with Single App Mode, you don't need to do most of the above - but it's a 'belt and braces' approach.

Dedicated Device Single App Mode

Within Configurator, right click the iPhone and select Start Single App Mode and select the app you made earlier. When it loads you should no longer be able to close it from the phone and your chosen webpage should load and be displayed full screen on the external monitor.

Done :-)

... or not.

Frustratingly, the free Apple Developer Account certificate has a very short life and the app will stop working after seven days - which is completely useless for our purposes.

There are two ways around this;

If your app doesn't care about date/time, just set the iPhone date to the past and ensure that the auto date/time functionality is turned off. This means you will need to use non https:// connections to your application because otherwise the certificate validation will fail.

The alternative, sadly, is to pay Apple for a Developer Account at ~£80/year. Which makes this less of a cheap option.

Of course, rather than using your own custom code above you could use one of the many Kiosk browsers on the app store. But, ultimately, I wanted to be able to use an Apple TV for this purpose too and Apple don't allow them to run browsers normally.