Text Message Sent Code Detection

Do you know when you use your phone for 2-step verification for websites and apps, that the vendor sends our phones a text message with a code. On iPhone, most websites and apps that do this bring up a small notification window for a few seconds so that we can just click on it and the code received can be entered into the verification field.

Do we have any plugins that can allow us to do this in our apps? If not, who is willing to create it for us and how much will it cost?

Firebase Auth plugin offers phone login, I believe I have textbelt plugin as well

Why do you need this for a game? i.e. what is your use case for 2FA?

@anon63346430, good question. Answer: Due to Google’s spam filters, they often send our game update emails to spam, so we have no way to recontact our customers without interference from Google. I’ve been working with them for 8 months without a solution, so it seems using a phone number to register with us is the only way we can be able to recontact our customers and grow the business. So, it will not be used for 2FA, but instead, as a means to communicate with them in the future. And in exchange, we will give them free gold and lives, just as we do for their email registration.

Asking for phone number access is going to scare most users! You would probably be best just asking them for it (though I very much doubt anyone will).

Have you tried making your emails less spammy, change the formatting (text to html ratio, etc.)?

Have you tried plain text for emails? They are more likely to get through.

@anon63346430, Agreed. Yes, I’m going to give the incentive with a “Maybe Later” button :slight_smile:

Does anyone have any code to implement this?

You might try this
textField:setNativeProperty( “textContentType”, “one-time-code” )

Does this need to be done from Native? I’m using stock Solar2D, not the Native version.


1 Like

@Scott_Harrison I have my own interface for entering the code manually. But what I’m really asking is, when a text message comes in for verification, if I click on it, the code goes to the app so that I don’t have to manually type it in. How can I tell the OS that I’m expecting a one-time code and then setup a call back to receive an incoming verification code?

You cannot, iOS acts as proxy between the messages app and your number input field. iOS basically is smart enough to stay “hey you are on a native code input field and you just got a text message with 6 digit code, I as the OS am going take control and present the user an option use that 6 digit code in this native input field”

@Scott_Harrison So we must use the native input field, we cannot create our own manually, right?
Is this handled the same way on Android?

You need to use this

I don’t use Android enough to answer the question but I assume so

@Scott_Harrison so I have this to capture the numeric input using native…

        local numericField
        local function textListener( event )
          if ( event.phase == "began" ) then
            -- User begins editing "numericField"
        -- Create text field
        numericField = native.newTextField( V.W40,V.H40, V.W20, V.H10 )
        numericField.inputType = "number"
        numericField:addEventListener( "userInput", textListener )
        numericField:setNativeProperty( “textContentType”, “one-time-code” )

But this next line does not work. How can I connect it?

numericField:setNativeProperty( “textContentType”, “one-time-code” )

Try this

numericField:setNativeProperty( "textContentType", "one-time-code" )

Notice the "

I’ve gotten the SMS one-time-code field working on iOS, thank you @Scott_Harrison. Does anyone know how to get it working on Android?

local oneTimeCode=math.random(8999)+1000  --creates code between 1001-9999
-- send this code via SMS
-- you'll have to use whatever means you have to send it

-- Create number input field
numericField = native.newTextField(V.W30,verifyInstructions_D.y+verifyInstructions_D.height+V.H02,V.W40,V.mainFontSize*1.5)
numericField.inputType = "number"
numericField:setNativeProperty( "textContentType","one-time-code")

local function numericListener( event )
  if numericField.text==oneTimeCode then
    -- put whatever code you want here when the oneTimeCode is either 1) typed or 2) comes in
numericField:addEventListener( "userInput", numericListener )

Does anyone know how to get Android devices to bring up an SMS passcode such that the user can click on it for it to be automatically entered into the native input field? Or is this even possible on Android? I have it working properly on iOS, but need help with the Android version.