Framework7 Notifications

Notifications are used to display required messages which appear like Push (or Local) iOS notifications.

Usage of Framework7 Notification:

IndexNotification UsageDescription
1)Notifications JavaScript APIThe notifications can also be added or closed with JavaScript by using the related app methods.
2)Notifications LayoutFramework7 notifications will be added by using JavaScript.
3)Example iOSFramework7 allows you to use different types of notifications in your iOS layout.
4)Example MaterialFramework7 notifications can also be used in material layout.

Notifications JavaScript API

You can use JavaScript with Framework7 notifications by using the following App methods:

myApp.addNotification(parameters): This method is used to add/show notification. It accepts required object with notification parameters. This method returns HTMLElement with notification element created dynamically.

myApp.closeNotification(notificationElement): This method is used to close specified notification, which accepts notificationElement as mandatory parameter and it is a HTMLElement or string of required notification.

See the notification parameter required when new notification is added:

IndexParameterTypeDescription
1)titlestringIt represents the notification title and is equal to notificationTitle app's parameter by default. It is used with iOS theme only.
2)subtitlestringIt represents the notification subtitle and is equal to notificationSubtitle app's parameter, by default. It is used with iOS theme only.
3)mediastringIt is the notification media element, which is an HTML string with icon or image. It is equal to notificationMedia app's parameter by default. It is used with iOS theme only.
4)holdnumberIt is used to close notification automatically after the specified timeout. It is equal to notificationHold app's parameter by default. It is used with iOS theme only.
5)closeIconbooleanIt is disabled to remove close icon from notification. It is equal to notificationCloseIcon app's parameter by default.
6)buttonobjectIt is the material notification button, which accepts 3 properties namely text, color and close. It is used with material theme only.
7)closeOnClickbooleanIf this is set to true then, notification will be closed after clicking on it. It is equal to notificationCloseOnClick app's parameter by default.
8)additionalClassstringIt is used to add additionally specified CSS class to notification element.
9)customstringWhen you want to use notification with custom HTML layout, this parameter is used. The title, subtitle, media and closeIcon parameters will be ignored while using this parameter.
10)onClickfunctionThis callback function will be executed after clicking the notification item.
11)onClosefunctionThis callback function will be executed when notification is closed.

Notifications Layouts

You can use JavaScript for notifications. It can also be used for custom styling. The Framework7 will put special notifications div to the body along with the list block, when you add notification.

iOS Example

Framework7 facilitates you to use different types of notifications in your iOS layout.

Example:

Let's take an example to demonstrate the use of iOS notifications in Framework7:

Test it Now

Framework7 Example Material

Framework7 notifications can also be used in Material layout.

Example:

Let's take an example to demonstrate the use of material layout notifications in Framework7:

Test it Now
Next Topic#