Read SMS message in iOS
Asked Answered
F

5

29

I'm an iOS developer and i have tried to build a mobile application with automatic activation functionality, i found more than way to read SMS message but only using private API which will cause Apple rejection to my app.,i have two questions and appreciate any feedback can help me.

  1. Is there any way to read SMS message in iOS platform without facing Apple rejection?
  2. Can anybody provide me with the related section in Apple developer documentation, the section that describe that its not allowed to read SMS message in iOS platform?
Fidgety answered 24/4, 2013 at 9:4 Comment(2)
Can you provide the link of the private API?Zeniazenith
Hi, Can you please tell about this private api?Microcurie
D
31
  1. No, there is no way to read SMS messages. Apple is very strict on this due to privacy concerns.
  2. Log in to the developers portal and click App Store Review Guidelines.

Nowhere in the guidelines does it specify that you can't access the SMSes. But you can only access if you use private methods which is not allowed and will get your app rejected.

You can only access data for which Apple supplies a documented API. You can not access files outside of the Sandbox of your App unless Apple provides an API for it.

Diplomatic answered 24/4, 2013 at 9:7 Comment(16)
HI, can you please tell me about this api?Microcurie
Which API are you talking about?Diplomatic
help.getpebble.com/customer/portal/articles/… How pebble does this?Microcurie
They register the watch with iOS with the bluetooth protocol for receiving notification. You can't acces them in your own app.Diplomatic
They have taken permissions from apple? Or this is a public API?Microcurie
No this is part of the bluetooth protocol, it has nothing to do with the app.Diplomatic
mspy.com/… Any idea about this?Microcurie
Yes they use the iPhone back which they open and read the message database. This is not possible from an iOS app.Diplomatic
Hi, can you tell in detail please. Its like through iphone backup through itunes?Microcurie
No I can't I have never done it, also you should really post your own question and not hijack this one.Diplomatic
@daylight It did mention that you could not access the messages. But I think they have changed it due to the introduction of iMessage Apps.Diplomatic
@Diplomatic How app like Truecaller read SMS ?Spoilfive
@Spoilfive they don't, Apple has not public API for reading SMS.Diplomatic
@Spoilfive Have you discovered how Truecaller access SMS messages? Did they jailbreak? I wonder if it has anything to do with Intents and Siri and Search. NSExtensionContext has an intent property for 3rd party messaging apps. When we do a search using Siri or by when we swipe right on the home screen to access the screen with that has widgets and a search bar at the top, content in messages can be found. I wonder if there is an api to access that search capability, or to access the search capability in the Messages app when we search using the search box in Messages.Stereoisomerism
@Microcurie Did you ever find a way to access content in Messages app in iOS that is approved by Apple. I detailed some ideas in my message to Bawantha above this message to you. Will any of those ideas work?Stereoisomerism
No. Apple doesn't allow to read sms.Microcurie
W
21

UPDATE

From iOS 12 Apple has given support to read the security code (OTP - One Time Passwords) in text fields.

oneTimeCode

Specifies the expectation of a single-factor SMS login code.

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

yourSingleFactorCodeTextField.textContentType = .oneTimeCode

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

Warning

If you use a custom input view for a security code input text field, iOS cannot display the necessary AutoFill UI.

Security Code Autofill

Waddington answered 13/6, 2018 at 5:52 Comment(2)
can this be achieved if I am making an iOS app using Ionic or Flutter? And does Apple allow publishing apps that include this feature?Reactionary
And does Apple allow publishing apps that include this feature? - Yes It's apple's feature only @AliHaiderWaddington
N
8

From iOS 12 Apple will supports Password AutoFill on UITextField, UITextView, and any custom view that adopts the UITextInput protocol. System keyboard set the textContentType on it to .oneTimeCode

  • Using 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.

It only works with System keyboard. So avoid using the custom keyboard.


And for more information, you will also review WWDC 2018 Session 204 - Automatic Strong Passwords and Security Code AutoFill and jump to 24:28 for automatic pre-fill the OTP.

iPhoneX image

Natica answered 24/9, 2018 at 3:21 Comment(0)
L
6

Support - Since iOS 12

Flow, Automatically fill in SMS passcodes on iPhone - https://support.apple.com/en-in/guide/iphone/iphc89a3a3af/13.0/ios/13.0

Implementation Guide - https://developer.apple.com/documentation/security/password_autofill/enabling_password_autofill_on_a_text_input_view

When you sign in to some apps and websites, a one-time SMS passcode is sent to your iPhone. As a security measure, you are required to enter the code into the app or website. iPhone can detect the passcode in Messages and display it above the keyboard.

To use the passcode, tap it.

enter image description here

Lambkin answered 5/5, 2020 at 6:50 Comment(0)
B
3

For Swift 5:

From iOS 12 Apple has given support to read the security code (OTP - One Time Passwords) in text fields.

if #available(iOS 12.0, *) {
               otpField.keyboardType = .default
               otpField.textContentType = .oneTimeCode
       } else {
               // Fallback on earlier versions

       }

Or you can add this contentType from storyboard like below:

enter image description here

Brainsick answered 22/7, 2019 at 9:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.