Explorations of apps for Apple's iMessage
Much of this work was during development of the Touchgram messaging platform.
Each sample will have its own nested readme document.
- imUrlData - Sending data via a URL
- imUrlDataApp - Sending data via a URL with app extends
imUrlData
adding a companion app that can send messages and shared state between the app and iMessage extension so the app changes settings affecting the UI in iMessage - imUrlDataAppSUI - re-implemented with SwiftUI 3 exercise in SwiftUI confirming can be used inside an iMessage extension
- responIM - Responding within a message
- imSkribble - Simple sketches going back and forth shows iOS17 side-effect with gestures.
- imPhoto - Using the camera and just sending in the message layout as normal media
- webFromIM - Launching a Web URL apparently trivial demo that you can launch Safari with a website from inside an iMessage extension.
- imPiggie copy of
imUrlDataApp
with the PostHog event processing package added, to prove events can be logged from inside an extension.
For various reasons, some of these samples may need to launch another app. This became difficult with iOS 13 so these samples were revisited.
- imPhoto launch Settings to change camera permissions
- imUrlDataApp launches the companion app, just to show it's possible.
- webFromIM sole reason for this demo is to launch Safari.
The samples imUrlDataApp and imPiggie support sending from inside the app, rather than only the iMessage app extension.
The button to send is enabled by checking MFMessageComposeViewController.canSendText and so will be disabled on simulators.
Note the presence of an idea below is not a guarantee the idea is feasible or that I have time to attend to it!
- A pure app version of
imPhoto
that usesMFMessageComposeViewController
to test sending without going into iMessage - Sending a photo as special data via a cloud service, so the receiving app can process it
- Sending photos using
MSMessageLiveLayout
to continuously update in the transcript
Also, any nested folders in this repo which are not linked above may be incomplete samples. Please add an issue if you think something should be mentioned here, I may have just forgotten it. Also add issues for anything that is unclear in the docs or source!
Due to some painful debugging experiences, I took the approach of doing simplest-possible testbed apps for different technologies.
This means if you are interested in a given sample, there's a better chance of it continuing to work than if you have to fix bugs in areas not of interest. It also means you can submit a PR to fix a single sample, so is less work to contribute ;-)
In many cases, Apple's documentation provides snippets and API documentation but no full sample you can build and verify works.
I love the effort some people put into their sample code but it's often frustrating when they explore several things at once. I'm testing this API and learning Reactive Cocoa because those complex samples tend to be left to wither - they are too hard to maintain when someone loses interest.
Some of the sample code might be factored out into multiple classes or extensions in a real app but I find it easier to browse when all is in one file.
Keeping a very similar code layout between different samples should also make it easier for you to compare and see how they differ. That's why the default view controller hasn't been renamed.
Even though these are relatively trivial test apps, I take the time to add a unique icon to them.
I have found, when you have more than one test app, especially with minimal UI, being able to pick the icon avoids stupid mistakes. In particular, with iMessage apps, icons need to stand out in the app picker strip.
I created a Sketch file initially in the imUrlData sample which is based off Apple's icon template (as of Sketch 52.6) but extended a bit for the iMessage icon sizes which are non-square.
I wouldn't regard myself as more than a very amateur designer. Even with that disclaimer, these do not represent my best work!
This started as a private repo (thanks MS/GitHub for introducing these) so I could work up some tests without public embarrassment then decide to publish.
I made it public so I could link to it from some Stack Overflow answers. In the near future there will also be articles on iMessage programming somewhere on Medium
These are very simple technical exploration apps. Some of the coding in them is simpler and may take minor shortcuts or lack error checking. Please don't judge me harshly by them. I'm sure there are smarter Swift idioms I could have used in some cases.