This example demonstrates how to integrate MFi-capable Reach receivers into an iOS app. It covers:
Requirements:
- A physical device with iOS 17+
- Xcode 26
- An active Apple Developer Program membership
- A Reach receiver with MFi support
How to run the app:
- Open the ReachMFiExample.xcodeproj.
- Select your development team and provide your own bundle ID.
- Build and run the app on a physical device.
The app uses the External Accessory framework to communicate with Reach receivers via Bluetooth Classic.
Add the UISupportedExternalAccessoryProtocols entry to Info.plist and list the supported protocols:
com.emlid.nmeafor reading NMEA messagescom.emlid.correctionsfor sending corrections
For background communication, include external-accessory in UIBackgroundModes.
To learn more about background modes, see Apple's documentation.
Call registerForLocalNotifications on startup to receive EAAccessoryDidConnect and EAAccessoryDidDisconnect through NotificationCenter. Both notifications provide an EAAccessory instance in their userInfo dictionary under EAAccessoryKey. Use connectedAccessories to find accessories that are already connected when the app launches.
Notification registration and handling are shown in MyApp.swift and ContentView.swift.
ReceiverConnection.swift manages communication through a separate EASession for each protocol. Each session provides an inputStream and an outputStream; this example reads from the NMEA session’s input and writes to the corrections session’s output.
The openStreams method configures and opens these streams, while the StreamDelegate implementation handles incoming events. Pass correction data from the NTRIP server to send(corrections:). On disconnection, closeStreams closes the streams and removes the associated data.
An MFi-capable receiver can supply location data to iOS through Core Location. Check out DetailMapView.swift and the CLLocation.sourceInformation documentation to learn more.
NTRIPClient.swift provides a basic, intentionally incomplete NTRIP client.
Its limitations include:
- Sending the receiver’s position to the NTRIP server as NMEA GGA messages is not supported. When VRS is used, the server requires continuous position updates to produce corrections and may disconnect if those updates are not provided.
- NTRIP 2 responses (
HTTP/1.1 200 OK) are not supported.