audio
UIBackgroundMode
to Clip’s Info.plist
to prevent iOS from suspending Clip as long as we’re playing audio. Using a silent audio file I made with Garageband, I wrote some code to “play” Silence.m4a
on loop, and also present local notifications every second (so I could track Clip running in the background). I then installed Clip to my phone, launched it without Xcode attached, and returned to the home screen. A notification appeared — but I kept waiting since I knew iOS apps could run for a few seconds before getting suspended. 5 seconds passed…then 10 seconds….then 30….and notifications kept appearing each second. I happily let it run for another several minutes, but it soon became apparent this would work after all! ?UIPasteboard
API. As of iOS 9, however, calling this API from the background will fail, preventing random apps from snooping on your clipboard from the background. Obviously this was a big problem for Clip, so I had to somewhat think outside the box to come up with a solution.AVAudioEngine
, I piped that audio stream through the Audio Unit extension to make sure it was always running alongside Clip. Clip could finally monitor the clipboard while running indefinitely in the background, which meant it was time to polish up a 1.0.print(UIPasteboard.general.string)
to print the contents of the clipboard when the extension launches, then had Clip repeatedly schedule local notifications. I ran Clip on my device, returned to the home screen, then waited for a local notification to appear. Once one did, I pulled it down to open it and…my iPhone’s clipboard contents were printed in Xcode’s console! It worked! ?ExposureNotification.framework
, Apple’s COVID-19 contact tracing framework.