8pods
Sending messages and data between watchOS and iOS apps
is possible thanks to Apple's work on WatchConnectivity
,
however there are a lot of delegate callbacks to work with,
plus some of the API calls are similar and it's not really
clear which is needed for what purpose.
Communicator
means you don't have to spend any time writing a cross-platform wrapper around WatchConnectivity
and is extremely easy to use.
Each app gets its own shared Communicator
object to use which handles all the underlying session stuff:
swift
Communicator.shared
Usage between the two platforms is identical, so you can use it in a shared framework with no workarounds.
Here's how you send a simple message with Communicator.
swift
let message = Message(identifier: "1234", content: ["messageKey" : "This is some message content!"])
try? Communicator.shared.send(immediateMessage: message)
This will try to send a message to the counterpart immediately. If the underlying session is not active, the try
will fail and Communicator will throw
an error you can catch if you want.
On the other device you register as an observer for new messages:
swift
Communicator.shared.messageReceivedObservers.add { message in
if message.identifier == "1234" {
print("Message received: (message.content)")
}
}
The great thing about using this style of observing means that you can observe these messages from anywhere in your app and filter out the ones you don't care about.
Communicator
can also transfer Blob
s and sync Context
s.
Blob
s are perfect for sending larger amounts of data (WatchConnectivity
will reject large data in Message
s), and will continue to transfer even if your app
is terminated during transfer.
You can use a Context
to keep things in sync between devices, which makes it perfect for preferences. Context
s are not suitable for messaging or sending large data.
License: MIT
Feedback is a really easy way to provide nuanced and helpful feedback to your users on iOS. Feedback comes in the form of haptics, or sounds, or both. With Feedback you can use the default sounds for different types of feedback, or provide a custom sound to use.
License: MIT
Apple's UIFeedbackGenerator subclasses are not difficult to use, but they are messy. HapticGenerator tidies this up and makes the process of creating different types of haptics on iOS easy and coherent.
License: MIT
ShowTime displays all your taps and gestures on screen, perfect for that demo, presentation or video. One file is all you need to turbo-boost your demos. ShowTime even displays the level of force you're applying, and can be configured to show the actual number of taps performed. Apple Pencil events are configurable and disabled by default. ShowTime works with single- and multi-window setups. ShowTime works best when mirroring your screen or recording through QuickTime. By default the size of the visual touches are 44pt; this mirrors Apple's guidelines for minimim hit size for buttons on iOS. You're free to change this, of course! Showing your gestures during demos helps give your audience a much clearer context on what's happening on your device. Consider trying ShowTime for your next demo!
License: MIT