Read SMS message in iOS - ios

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.
Is there any way to read SMS message in iOS platform without facing Apple rejection?
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?

No, there is no way to read SMS messages. Apple is very strict on this due to privacy concerns.
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.

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.

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.

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.

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:

This is not possible on iOS. Apple provides no public APIs to access the users messages.

Related

How to read Incoming SMS - iOS [duplicate]

In my application I am able to send an SMS programatically to a particular mobile number when the user clicks submit button. Then there is a response message from that mobile number now I want to read that message and populate that SMS text in to my application.
I searched for this and found that this is not possible in iOS.
My question is there any possibility accessing inbox SMS with user permissions?
Simply two words from Apple:
Not Possible
Detailed:
An iOS app can only access the data for which Apple supplies a documented public API. iOS can not access outside of the sandbox until Apple provides a public API for it. So intercepting/reading an incoming SMS not possible. And no idea when the iOS device is jailbroken.
No it's not possible in iOS, it's possible on jailbroken devices but you can not place your application in the App Store.
You can't read SMS, but you can auto fill a text field from SMS.
From Apple Documentation :
To ensure your text input view displays the right AutoFill
suggestions, set the textContentType property on any relevant input
views.
so you can do the following :
textField.textContentType = .oneTimeCode
More info :
check the link here

Custom Keyboard Full Access Rejection

I had made a custom sticker keyboard. Basically users touches one of the gif images that I have placed on the keyboard, i do a a copy action on that image and then the user pastes it to iMessages. For this to work i need to have user do "Allow Full Access". Without it the copy action doesn't work. Now, my app got rejected with this message
From Apple
25.5 - Keyboard extensions must remain functional with no network access or they will be rejected
25.5 Details We noticed that your keyboard extension does not function when the “Full Access” setting is toggled off.
Is there anything i need to set in my info.plist file? Did the reviewer didn't understand how my app works i.e. need to do rejection appeal or do I need to do something else? Trust me i googled but didn't find much on this topic
Here's the answer to my question that eventually led to my app approval.
It doesn't matter if your app is custom sticker keyboard only. It "must" have "both" alphabet and numeric keyboards. If it doesn't then it will be rejected.
From Apple Review Guidelines
4.4.1 Keyboard extensions have some additional rules.
They must:
Provide keyboard input functionality (e.g. typed characters);
Provide
a method for progressing to the next keyboard;
Remain functional
without full network access;
Provide Number and Decimal keyboard
types as described in the App Extension Programming Guide;

Read verification code automatically and access for Login in App in iOS

I am creating one App and it has verification phone number required functionality which allow user to enter into App. We send sms to the Users through the gateway and we need to read verification code directly from the SMS without typing code into App. But don't know how to read verification code automatic from the SMS and access in my App.I have gone thorugh the searches for this but could not find any path to move ahead. Is it allow in iOS and if Yes, can anyone tell me what to do to achieve it. Thanks.
Apple added this feature in iOS 12
just add:
if #available(iOS 12.0, *) {
self.verifyCodeTextField.textContentType = .oneTimeCode
}
to your controller and make sure your SMS has "Verification code", "code", "Login code" in it and apple will read those messages and show the last 1 minute received code on top of your keyboard for verifyCodeTextField.
You can check your SMS and there is a line under the number it means apple has detected it in your SMS and you are good to go.
If other people know the keyword in other languages that helps apple to detect the code I would love to know them.
From iOS 12 it is possible to improve the user experience for native textField (actually anything that implements UITextInputTraits to be precise) by:
myOTPTextField.textContentType = .oneTimeCode
More information can be found in docs
For the HTML you can achieve it by:
<input id="my-one-time-password-textfield" autocomplete="one-time-code"/>
More information can be found in docs
Your app can not read directly from the list of SMS messages. That would be a security risk.
But a couple things you can do would be 1:
allow the user to type in the verification code from the SMS (that seems to be the standard thing for most apps)
2:
use a custom URL scheme such as "myapp://verfication:12345" that when clicked in a SMS, goes straight to your installed app and does the verification. Here is a tutorial on how to do the Custom URL scheme thing.

Is there any Incoming SMS Broadcast Receiver like Receiver in iOS

I need to verify account using reading sms and then matching the verify code.
Android have such functionality like :
where they can read sms and check a particular value.
Need to verify account using text messages without open the text message like in Whatsapp used in Android.
Is there any NSNotification Center etc in iOS to serve this task?
There is no way to do this on iOS, since your app does not have acces to the incoming text messages.
Also it is disallowed by the AppStore review guidelines due too privacy concerns.
You can get OTP from your message.
otptextField.textContentType = .oneTimeCode
Can please get the project from his link.
https://github.com/karthickkck315/Automatic-OTP

How Can We Read Incoming SMS by using Application in iOS

In my application I am able to send an SMS programatically to a particular mobile number when the user clicks submit button. Then there is a response message from that mobile number now I want to read that message and populate that SMS text in to my application.
I searched for this and found that this is not possible in iOS.
My question is there any possibility accessing inbox SMS with user permissions?
Simply two words from Apple:
Not Possible
Detailed:
An iOS app can only access the data for which Apple supplies a documented public API. iOS can not access outside of the sandbox until Apple provides a public API for it. So intercepting/reading an incoming SMS not possible. And no idea when the iOS device is jailbroken.
No it's not possible in iOS, it's possible on jailbroken devices but you can not place your application in the App Store.
You can't read SMS, but you can auto fill a text field from SMS.
From Apple Documentation :
To ensure your text input view displays the right AutoFill
suggestions, set the textContentType property on any relevant input
views.
so you can do the following :
textField.textContentType = .oneTimeCode
More info :
check the link here

Resources