Created
July 4, 2019 10:26
-
-
Save MaatheusGois/e42dba47907b684f99aab7a3d21ea032 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| import UserNotifications | |
| class ViewController: UIViewController { | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| } | |
| //Enviando a Notificação | |
| //O appDelegate é chamado para usar seu novo método de notificação | |
| var appDelegate = UIApplication.shared.delegate as? AppDelegate | |
| //Botão de ação | |
| @IBAction func botaoEnviarNotificacao(_ sender: Any) { | |
| //Nas variáveis abaixo definimos o corpo da mensagem | |
| let titulo = "Aqui vai o título" | |
| let subtitulo = "Aqui vai o subtítulo" | |
| let mensagem = "Aqui colocamos o corpo da mensagem" | |
| //O identificador serve para o caso de queremos identificar uma | |
| //notificação especifica | |
| let identificador = "identifier\(Int.random(in: 0..<6))" | |
| let tempo:TimeInterval = 0.1 | |
| //Chamando o método | |
| self.appDelegate?.enviarNotificacao(titulo, subtitulo, mensagem, | |
| identificador, tempo) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment