Listen to the navigation bar click event
This topic guides you through how to listen for the mini program navigation bar click event.
Overview
From IAPConnect 2.34.0, Griver supports click event callbacks when clicking items on the navigation bar. By implementing GRVNavigationBarEventDelegate
, the method is called when a user clicks an item on the navigation bar. The following sections provide the detailed steps:
Step 1. Implement GRVNavigationBarEventDelegate
Implement the GRVNavigationBarEventDelegate
protocol, and implement the methods defined by the protocol. Currently, you can receive the following three types of click events:
GRVNavigationBarItemClickedTypeBack
: The user clicks to return to the previous page.GRVNavigationBarItemClickedTypeCloseApp
: The user clicks to close the current mini program.GRVNavigationBarItemClickedTypeOptionMenu
: The user clicks to show the options menu panel.
See the following sample code:
copy
class DemoNavigationBarEventDelegate: NSObject, GRVNavigationBarEventDelegate {
// navigation bar item was clicked
func navigationBarItemDidClicked(with type: GRVNavigationBarItemClickedType) {
print("navigationBarUIElementDidClicked: \(type)")
}
}
Step 2. Configure GRVExtensionDelegate
for navigationBarEventDelegate
Configure yournavigationBarEventDelegate
class as extensionDelegate.navigationBarEventDelegate
:
copy
let extensionDelegate = GRVExtensionDelegate()
extensionDelegate.navigationBarEventDelegate = DemoNavigationBarEventDelegate()