read received SMS in unity for android

Started by
1 comment, last by SyncViews 5 years, 7 months ago

 

 

i have an sms verification system. that verification code will be sent to user phone. i want to read it automatically and add it to a text field in Unity. how can i do that?

Advertisement

You will need to use the Android API BroadcastReceiver and registered with SMS_RECEIVED_ACTION (can be done statically in XML). For Unity you should be able to access those by using a plugin, see https://docs.unity3d.com/Manual/PluginsForAndroid.html.

However, Id note that as a Android user, generally Id not give some random game off the app store the RECEIVE_SMS permission required for that.

Is your purpose to validate the phone number of a user account? You can get the number with TelephonyManager but again it needs a permission (READ_PHONE_STATE).

 

Both RECEIVE_SMS and READ_PHONE_STATE are considered dangerous permissions and may be denied and even revoked after installation.

This topic is closed to new replies.

Advertisement