Here's how to implement real-time support in your iOS app with Swift

by Adrian Perțe, iOS Lead Engineer


Looking for an easy way to add real-time support to your iOS app? In this article, we’ll show you how to do it with Swift and iMessage. You read that right. iMessage.

Two years ago, we decided to cancel our pricy Intercom subscription and spent the weekend thinking of a reliable, fast and private way to assist the thousands of people who use WeatherKit. Since then, we've also automated replies to some frequently asked questions, so we can focus on the more complex issues.

Alternatives to Intercom that we have considered

  • Mail? People are scared that you're adding them to your newsletter. As much as we love email (we really do), it's not the best way to communicate with your users.
  • Intercom-like solutions at scale can be pricy and they collect too much information about the user. Over the past years, this has become less and less true, but there's a hidden cost of implementing an Intercom-like SDK.
  • Apple's Business Chat, which is in beta. We're currently being reviewed by Apple for access to it. We'll update this article once we have more information.

Why iMessage?

We know people love their blue chats and badges. We also know that iMessage is a reliable way to send messages to people. It's also private and secure - and more often than not, we, as indie developers, are using it on a daily basis to communicate with our family and friends. On the other side of the spectrum, the people that use WeatherKit are also very familiar with it.

Swift + iMessage = Real-time support

Use this snippet of Swift code to implement real-time support in your iOS app. It will open iMessage and pre-fill the message with a body of text that you can customise.

  @IBAction func supportiMessage(_ sender: Any) {
        let body = "Change this text and ask the people to send this first message, where you can also include things that can help you debug their situation like the app version."
        let sms = URL(string:"sms:{{yourAppleID}}&body=\(String(describing: body.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!))")!, options: [:], completionHandler: nil)

Make sure to change the {{yourAppleID}} above with your Apple ID. You can find it in the Messages app, by tapping on your name.

Additionally, in your Info.plist file, you'll have to add sms to LSApplicationQueriesSchemes. It was that easy!

Ultimately, this might not be for everyone — but it felt right for us and for our volume of support. These 10 minutes of work turned out to be a really good deep dive into how to offer a good customer support solution while keeping the costs down. By down, it's free.

Will it pass the App Store review?

Four days ago WeatherKit passed Apple's app review with brio, so you can try it out from your iOS device. In our case, adding this unique support method was the right call with more than 95% of the help requests being through iMessage.

P.S. Remember Apple's Business Chat? It's been in beta for more than a year now and Apple could open up the API for the developers. Using that, we could have real-time diagnostics and data about the device, offer a simple way to review the app after issues were solved. That little thing could scale and we're sure that many developer would adopt it. Apple?

Try out WeatherKit for free

More articles

How hard is it to build a native macOS app with SwiftUI?

It's been a number of years that we could do this already. Is it now the moment to ditch Electron apps? Let's find out.

Read more

Is 2023 the Time to Fully Switch to SwiftUI?

As SwiftUI matures and continues to disrupt the app development landscape, developers are asking the key question: Is it time to fully embrace SwiftUI? This article explores the pros and cons of this pivotal decision.

Read more

Tell us about your project

Our offices