Intercepting iOS Notifications

‘In the interest of science’, we wanted to find out if we could intercept and evaluate all notifications arriving on an iOS test device. While investigating, we came across the Apple Notification Center Service. This service allows bluetooth peripherals to connect to an iOS device and get notified when a push notification is received on the lock screen.

We tried implementing ANCS service into a sample app to see if we could catch the notifications being sent to one of our test devices. A Mac application would then act as the consumer of these notifications, using CoreBluetooth. Unfortunately, after a bit of tinkering around, we soon realized this wasn’t going to work :(. According to this forum post on the Apple Developer Forum the ANCS is no longer consumable in CoreBluetooth.

So what does this mean?

Using CoreBluetooth you can set up two sides. A central, being the thing that wants to connect (the Mac), and a peripheral, being the thing you want to connect to (the iPhone). On the peripheral you would advertise that you have a particular service. On the central you can scan for peripherals with a specific service by scanning for the service’s UUID.

Now you would imagine it fails here, but it doesn’t, you can actually see al the devices that are advertising this service. Once you select the correct peripheral, you can connect to it and ask for its service. This is the point of failure. You can retrieve all the services from the peripheral, with the exception of the ANCS. Hence the ‘consume’ part in the previously mentioned forum post.

Conclusion

While it’s perfectly possible to use ANCS to retrieve an iPhone’s push notifications on the lock screen under the right conditions, you can’t consume the service using CoreBluetooth in iOS or OS X. Our preliminary attempts to consume the service using an Android device seem hopeful though. You can also imagine using a Raspberry Pi or an Arduino to act as the central in the previously mentioned example.

If you have an other solution to this problem feel free to enlighten us!