Passar dados entre dois aplicativos por esquema de URL rapidamente?
Existem dois aplicativos de teste chamados Sender & Receiver
Eles se comunicam pelo Url Scheme. Gostaria de enviar uma String do remetente para o destinatário, isso é possível?
Detalhe sobre a String:
Ambos crio campos de texto no remetente e no destinatário; gostaria de enviar um texto para alguma string no campo de texto do remetente. Quando clico no botão, a String será exibida no campo de texto do receptor.
Aqui está o código do meu App Receiver:
Em Appdelegate
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
calledBy = sourceApplication
fullUrl = url.absoluteString
scheme = url.scheme
query = url.query
}
Controlador de exibição
override func viewDidLoad() {
super.viewDidLoad()
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(ViewController.displayLaunchDetails), name: UIApplicationDidBecomeActiveNotification, object: nil)
// Do any additional setup after loading the view, typically from a nib.
}
func displayLaunchDetails() {
let receiveAppdelegate = UIApplication.sharedApplication().delegate as! AppDelegate
if receiveAppdelegate.calledBy != nil {
self.calledByText.text = receiveAppdelegate.calledBy
}
if receiveAppdelegate.fullUrl != nil {
self.fullUrlText.text = receiveAppdelegate.fullUrl
}
if receiveAppdelegate.scheme != nil {
self.schemeText.text = receiveAppdelegate.scheme
}
if receiveAppdelegate.query != nil {
self.queryText.text = receiveAppdelegate.query
}
}
Agora, só posso mostrar as informações sobre o URLcomo isso
Espero receber alguma sugestão!