I want to make a dialog that ask for a received sms code.
The oficial form is by a parameter of the UITextField but in Pythonista there is not implemented yet. How can I make it by ObjC? I can not import UIKit by ObjCClass because Pythonista drops an error.
Thanks you in advance.
Now THAT I don't know...
what does tfo.textContentType() return?
I think you'd have to text yourself from another phone with a text that has a code. Then you might need to have the auto correct/suggestion thing above the keyboard enabled, and it should show the code as a suggestion.
From stack overflow
First of all, the SMS need to have the keyword "code" or "passcode" into their message, and don't use spaces after the code. if you received the SMS and you have the button "Copy Code" then it will works
@cvp are you on ios12?
Seems like this didn't actually work...
@JonB iOS 12.1, but don't forget I am not the requester. I only tried to help, without success if without you 😢
It works perfectly.
You can try the code using other content type like phone number.
import ui from objc_util import * load_framework('UIKit') UITextContentTypeOneTimeCode=c_void_p.in_dll(c, 'UITextContentTypeTelephoneNumber') if UITextContentTypeOneTimeCode: UITextContentTypeOneTimeCode = ObjCInstance(UITextContentTypeOneTimeCode) tf = ui.TextField() tf.keyboard_type = ui.KEYBOARD_NUMBER_PAD tfo=tf.objc_instance.textField() print(tfo.setTextContentType_.encoding) my_method = ObjCInstanceMethod(tfo, 'setTextContentType_') my_method.sel_name='setTextContentType:' my_method.encoding=b'v@:@' my_method(UITextContentTypeOneTimeCode) tf.present('sheet')
I couldn’t answer to you before because I was working.
@AlbertoAEC and you can comment the load_framework, I think
@cvp yes, load_framework is no needed.
Thanks to both of you for your time