15

There have been tons of questions on how to programmatically access the SMS messages stored in the iPhone. Doing a small research you will quickly and sadly find out that Apple won't let us developers touch the SMS API or SMS database due to obvious security reasons. Let's set this fact apart for a moment.

I own a BMW car that comes equipped with a fantastic "infotainment" system called iDrive. Just recently I realized that I could actually read incoming text messages through the iDrive system when my iPhone is connected to the USB. That really intrigued me. After playing around with the car and the phone configuration, I finally figured out that the iDrive was actually displaying text messages from the Notification Center. This means that every time I get a new message, it would be displayed as a notification in the lock screen and the car would be able to access it because Notification Center has public APIs. As soon as I removed the Messages app from the notification, I got nothing back.

As many of you have thought before, I also wanted to create an app that could monitor incoming text messages and take some action based on keywords scanned from the message body.

Until now, I was really inclined toward moving to Android in order to set me free, however, watching the car displaying incoming text messages makes me see some light at the end of the tunnel.

Does anybody have a clue on how to build an iOS app that can read entries from the Notification Center? I tried some research but this seems to be such a broad matter that it can be difficult to find specific documentation for iOS Notification Center.

I should mention that I am not an experienced iOS developer, so any help will be very appreciated.

BTW - I can never understand Apple official documentation support anyway. Kind of confusing to find a complete example of a running app.

UPDATE: It is already 2021, Apple is about to release iOS 15 and we still don't have an API that allow access to the SMS database.

7
  • I don't know if the iDrive system does Bluetooth, but Bluetooth accessories can read notifications developer.apple.com/library/ios/documentation/CoreBluetooth/…
    – SomeGuy
    Commented Jul 24, 2015 at 4:06
  • Thanks for the comment @SomeGuy I don't think I had the bluetooth on when the messages were comming, but even if having the bluetooth turned on is a requirement, it is still an interesting solution for me. Will try to research through this path and will update here. Commented Jul 24, 2015 at 12:53
  • @Fabio Moggi +1 This question is very interesting did you ever find out how iDrive was doing it?
    – Apqu
    Commented Jan 2, 2016 at 23:51
  • @Tur I just gave up on that as I am not a very skilled objective C developer. I am using the iTunes backup in order to get access to the SMS database. Commented Jan 11, 2016 at 14:22
  • 1
    @YonathanGoriachnick the approach I took several years ago was to trigger a backup on iTunes and once it was complete, I extracted the exact file that contains the sms.db. It was a pretty manual process with no simple workaround. Last year I finally found a solution to this issues: bought myself a Galaxy S20 with Android 11 =) Commented May 20, 2021 at 0:18

4 Answers 4

12

in iOS 12 Apple provided an option to read SMS (OTP Password)

If the system can parse a security code from an SMS message, the QuickType bar shows the code for up to three minutes after it has been received. If a security code arrives while the text input view is selected, the system pushes the incoming code to the QuickType bar.

To test the format of your SMS code for different languages, text a message to yourself. If you receive a message with an underlined security code, tap on the code. If a Copy Code option appears, the system has recognized your code.

iOS supports Password AutoFill on UITextField, UITextView, and any custom view that adopts the UITextInput protocol.

You can autocomplete security codes from single-factor SMS login flows

Programmatically

yourTextField.textContentType = .oneTimeCode

Storyboard/XIB

Select UITextField/UITextView in storyboard/XIB click Click on Attribute inspector. Go to text input trait, click to Content type and select one-time code and done.

enter image description here

Before implementation please make sure

  • If you use a custom input view for a security code input text field, iOS cannot display the necessary AutoFill UI.
  • It only works with System keyboard. So avoid using the custom keyboard.
2
  • Thanks for the detailes here, but the reason to read incoming text messages is not related to a one time code. I truly need to read the message body and input data into some databse. Commented Apr 10, 2019 at 3:32
  • Is there any special requirement as to the SMS message? Any special format?
    – Yar
    Commented Apr 20, 2020 at 11:29
4

The MFi program from Apple allows a chip to be installed on the host

and Bridge API provided pass through of the notifications or messages, call logs etc., to the connected device (This works over Lightning, 30 pin and Bluetooth)

This notification center access can be disabled by toggling of the app in Notification Settings.

As far a to do with in an App is not available through any of the published APIs

2
  • 1
    can u give me any apple's document where it is mentioned? Commented May 27, 2019 at 6:52
  • Any documentation please? Commented Jan 17, 2023 at 10:18
4

You can read data from notification tra, Apple Notification manager library is open, we can implement it. just read every notification for incoming sms and if match found then fire your functions

2
  • Very appreciated for your answer. Would you have any example to support reading incoming notifications on iOS11 other than the official Apple documentation? Commented Jan 7, 2018 at 21:43
  • Any documentation please ? Commented Jan 17, 2023 at 10:18
2

not possible with official SDK

you can only check is status is changed. so basically if you receive a notification

5
  • 1
    Somehow BMW managed to display incoming text messages on iDrive system. What you are saying is that they may have not used an official SDK to accomplish that? If so, would you recommend any SDK to make that possible? I believe that if BMW did it, why can't I? =) Commented Jul 24, 2015 at 12:48
  • maybe Apple have partnered with them for specially and only allowing them (car infotainment system manufacturers) to access the notification center apis Commented Jan 19, 2016 at 19:39
  • @MuhammadMamoorKhan I suspected it since the beginning. Still, I am pretty sure the infotainment system was reading SMS text messages from the notification center. Once I disabled it, it stop working immediately. Anyway - I don't even own the car anymore, so won't be able to investigate on that. Commented Feb 21, 2016 at 17:25
  • BTW - let's see what comes out of Samsung Unpacked 2016 today. Maybe it is time for a change. Commented Feb 21, 2016 at 17:27
  • 2
    @rayen-kamta can you elaborate a little more on your status comment? For instance, if I don't need to actually read the the contents of a message, but just understand when/if a particular user sent one to me. Is this possible?
    – Beak
    Commented Sep 28, 2017 at 17:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.