How to read a SMS in iOS and is it able to pass an

2019-07-14 22:37发布

问题:

do anybody know about how to read a SMS in iOS with Xamarin iOS ? and then I want to pass a string from that SMS to the application via link. For example when user click the link in the SMS it will pass a string value to the application and in the application a method is waiting to trigger that.

回答1:

It's impossible to read incoming or storing SMS's due to iOS security restriction.



回答2:

Although you can't directly intercept SMS messages, you can create a custom URL scheme so that if a user clicks a link in your message it will launch your app.



回答3:

If Jason's answer of using a link to the app, there is an alternative. In my case a web service is sending down a code (two stage auth). When I know its going to be coming, I prompt the user to looks for it, and when it comes long press the message bubble, and copy the whole message to the pasteboard.

When the user switches back to my app, I've set a flag to look at the pasteboard, I see the message, extract out the code, and if it "works" the user can continue without further interruption.

Not as elegant as Jason's answer, but if you cannot control the sms content, its an option.



回答4:

It is possible from iOS 12

textField.textContentType = .oneTimeCode

Please check this doc