Reputation: 1407
I want to add in-app notifications to my app to alert users about the action they have done. For example, when a user saves something, a small alert on top should come out telling him "hey, I saved this!".
This notification should be like instagram's notifications. You can see how instagram does this by sending a post in direct to someone (something along the lines "post xxx sent to username").
I am not sure how to achieve this, because this is not an actual notification, just something that appears to the user while in-app to tell him they've done something right.
How can I do this?
Upvotes: 0
Views: 191
Reputation: 718
If they are normal in app notifications (alerts) and not push notifications then the code would be something like this:
let Savealert = UIAlertController(title: "Alert!", message: "Saved!", preferredStyle: .alert)
Savealert.addAction(UIAlertAction(title: "OK", style: .dismiss, handler: nil))
present(Savealert, animated: true, completion: nil)
This is an alert that can be used to tell the user they've saved something and then later gets dismissed after the user presses "OK".
Upvotes: 0
Reputation: 3927
There a lot of third party frameworks that does this. Google for "toast ios", for example. After a quick search I found this library: https://github.com/scalessec/Toast-Swift
If you want to do it yourself, you need to create a view with your message, which you can then display.
Upvotes: 1