DEV Community


[iOS] show notification banner when foreground run

vominhhuy profile image Code Better #Sofast Updated on ・1 min read

Discussion (1)

vominhhuy profile image
Code Better #Sofast Author • Edited

With iOS >= 10, you can show notification banner when app run foreground. To make it, you can add some line code in AppDelegate.m

//Called when a notification is delivered to a foreground app.
-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void ()(UNNotificationPresentationOptions options))completionHandler
completionHandler(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge);

Don't forget, import UserNotification in head:


Hope it work with you.

Forem Open with the Forem app