Detect when a message is received on device
artainmo opened this issue · comments
Maybe create a notification once a message is received...
When receiving a text message, a new contact is instantly created with the number as the contact name.
The only way to detect incoming messages would be from incoming notifications.
Apple does not allow direct access to SMS.(https://stackoverflow.com/questions/31601552/how-to-programmatically-read-incoming-text-messages-on-ios).
I tried to access incoming notifications with this:
""" CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), nil, { (_, observer, name, _, _) in
print("Notification (String(describing: name)) received")
}, nil, nil, .deliverImmediately)
"""
However it did not work. I guess I am still able to receive messages but not able to indicate a message was received.
The associated bonus will have to be replaced by another bonus.