alert("I am an alert box!");
That's all it takes to create an alert using JS. If you want to try other types of popups using JS, check out here.
But, let's try with Swift.
let alertVC = UIAlertController(title: "Alert", message: "Testing", preferredStyle: .alert) let okAction = UIAlertAction(title: "OK", style: .default, handler: nil) alertVC.addAction(okAction)
Looking at the above, IOS needs a little extra code, doesn't it?
But, that's not the end, let's make it lesser, reusable and better.
How about this?
alert(title: "Alert", message: "Auto dismiss in 4 sec")
I've written an extension for UIViewController, which uses just the above one line code to display an Alert popup.
The extension covers all, I'd tried to make it as simple and usable as possible, you can download the source code from github and play with it, try to customize.