Push notifications are at the core of the Layer messaging service. Where some platforms provide push as a complementary offering, push is a fundamental pillar of our system. Every message that’s delivered to a device via Layer is optionally accompanied by a push notification, and this works across platforms and devices. Our fondness for the notification interface is one of the many reasons we’re so bullish on wearable devices and the possibilities they open up for application developers.
As we’ve written in the past, the Apple Watch provides a simple, convenient and discreet medium for delivering notifications. At Layer, our mission is to help developers build the very best messaging experiences, and we believe those experiences will undoubtedly involve Apple Watch applications. To learn more about what it’s like to build for this new medium, we started with a fully working iOS app and set out to make it work on the Apple Watch. Here’s what we learned.
This was the first time our iOS team had the opportunity to develop for Apple Watch, and we naturally experienced a small learning curve while getting started with the new platform. Here are a few areas that stood out.
Running and debugging
When developing for a new technology platform it can take a bit of time to become familiar with the tooling and workflow. Working with the
WatchKitsimulator was no exception and produced a few unexpected surprises.
- Displaying the Apple Watch Simulator – We expected to have the Watch simulator pop up when running our app extension target for the first time. As we quickly found out, a bit of setup was required to enable this behavior.
- Navigate to
Hardware > External Displays.
- Select either the 38mm or 42mm simulator.
- Navigate to
- Debugging extension and app simultaneously – App extensions can make calls to their parent application via the
openParentApplication:reply:API. This method calls the app delegate’s
application:handleWatchKitExtensionRequest:reply:method. We expected to be able to add a breakpoint into our implementation of this method while running the extension in the simulator, but the break point was simply not tripped. In order to debug applications on the iPhone and Watch simulators simultaneously, perform the following:
- Launch the
WatchKitapp target in the simulator.
- Open on the corresponding parent application in the iPhone simulator.
- In Xcode, navigate to
Debug > Attach to Processand select your iPhone application’s process.
- Launch the
Cocoa developers who have distributed iOS applications have undoubtedly run into issues that can arise from Provisioning Profiles and Signing Certificates. We weren’t surprised to encounter these issues when attempting to build our
WatchKit app on an actual device for the first time.
WatchKit Extension and Notification target both require their own unique Provisioning Profiles that must match their Bundle Identifiers. These will need to be generated in the Apple developer portal before building for an actual device.
We’re admittedly not the biggest Storyboard fans at Layer (and while the reasons for this are numerous, they’re probably best discussed in another blog post). Needless to say, we were somewhat disappointed to learn that Storyboards are mandatory for Apple Watch Apps and that layout shouldn’t be performed programmatically. This is a bit of a departure from the development philosophy of Atlas for iOS, where we try to perform as much layout as possible in code.
Push in the simulator
Lastly, one very pleasant surprise we encountered was the ability to simulate the delivery of a push notification to Apple Watch. Developers can define a push notification JSON payload in a
.apns file and have it “Delivered” to the
WatchKitNotification target. This provides very efficient notification debugging, especially when implementing push notification actions for the extension. Our hope is that Apple extends this functionality to the parent application targets in the near future!
The future with watchOS 2
We were excited to see Apple’s announcement yesterday of native application development for Apple Watch, and the new features in
WatchKit. Apple made a number of improvements that benefit messaging applications, especially with regard to interactive notifications and new APIs for Siri and the microphone. We’re looking at experimenting with the following functionality in
LayerKit and Atlas:
- Reply directly from a Notification on Apple Watch using voice or text, not just from the Watch Extension.
- Use Siri in the Layer-powered Watch app to reply directly to messages.
- Reply to a message using the microphone to send an audio message.
- View videos and GIF within message cells, adding to the current photo and map functionality.
- Display the last message or message count as a Complication, with new high-priority push, to keep a running history of replies on Apple Watch.
- Use custom Taptic vibrations depending on the sender of the message, or differentiated by 1:1 or group conversations.
We can’t wait to see what you’ll build for Apple Watch with Layer and Atlas. If you’re interested in getting early access, don’t hesitate to get in touch!