REPL Print Only Version

If you want to add more icon pairings, you'll need to know what sort of data ANCS is sending from the phone so you can match your icon to the app type.

This version of the code will give you just the emitted data! It's very informative to see what info comes along with your notifications. Just download the file and paste it into your Mu window, then save it to your Circuit Playground Bluefruit as

Pair your iOS device with the CIRCUITPY BLE device and you'll see lots of great notification info!

"""This demo shows the latest notification from a connected Apple device on the REPL and Gizmo"""
import time
import adafruit_ble
from adafruit_ble.advertising.standard import SolicitServicesAdvertisement
from adafruit_ble_apple_notification_center import AppleNotificationCenterService
from adafruit_gizmo import tft_gizmo

# This is a whitelist of apps to show notifications from.
#APPS = ["com.tinyspeck.chatlyio", "com.atebits.Tweetie2"]
APPS = []


def find_connection():
    for connection in radio.connections:
        if AppleNotificationCenterService not in connection:
        if not connection.paired:
        return connection, connection[AppleNotificationCenterService]
    return None, None

# Start advertising before messing with the display so that we can connect immediately.
radio = adafruit_ble.BLERadio()
advertisement = SolicitServicesAdvertisement()
advertisement.complete_name = "CIRCUITPY"

display = tft_gizmo.TFT_Gizmo()

current_notification = None
new_ids = []
displayed_ids = []
active_connection, notification_service = find_connection()
while True:
    if not active_connection:

    while not active_connection:
        print("waiting for connection...")
        active_connection, notification_service = find_connection()

    while active_connection.connected:
        current_notifications = notification_service.active_notifications
        for notification_id in current_notifications:
            if notification_id in displayed_ids:
                continue # already seen!
            notification = current_notifications[notification_id]
            category = str(notification).split(" ", 1)[0]
            print("Msg #%d - Category %s" % (, category))
            print("From app:", notification.app_id)
            if notification.title:
                print("Title:", notification.title)
            if notification.subtitle:
                print("Subtitle:", notification.subtitle)
            if notification.message:
                print("Message:", notification.message)
    active_connection = None
    notification_service = None

This guide was first published on Dec 20, 2019. It was last updated on Dec 20, 2019.

This page (ANCS Simple Demo) was last updated on Apr 13, 2021.

Text editor powered by tinymce.