Trying to make TCP connection with Google mail server through IMAP protocol with "Network framework" (Swift), but I got an error. I got code from this (wwdc2018) video.
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let connection = NWConnection(host: "imap.google.com", port: .imaps, using: .tls)
let myQueue = DispatchQueue(label: "test")
connection.stateUpdateHandler = { (newState) in
switch (newState) {
case .waiting(let error):
print("ERROR - \(error)")
case .preparing:
print("I am HERE")
case .ready:
print("HELLO")
case .failed(let error):
print("ERROR + \(error)")
default:
break
}
}
connection.start(queue: myQueue)
return true
}
My console displays:
I am HERE
ERROR - -65554: NoSuchRecord
UDPATED: Thanks to @arnt I remembered that host must be "imap.gmail.com", now works fine!
The main goal is to create TCP connection with Google mail server through IMAP protocol with "Network framework", but on Objective-C.