Customize predefined more menu items
The super app can customize the icon, title, and row layout of the SDK's predefined more menu items. These items include:
- Favorite/Unfavorite: Allows users to add or remove the mini program from their favorites.
- Notification: Allows users to view notifications.
- Subscription: Allows users to view subscriptions.
- Feedback: Allows users to submit feedback.
- Settings: Allows users to view and modify the mini program settings.
- About: Allows users to view the mini program information.
- Share: Allows users to share the mini program.
- Reopen: Allows users to reopen the mini program.
To customize these menu items, the super app must implement the GRVMoreMenuInfoDelegate
protocol. This topic covers the default user experience, implementation steps, and protocol details.
Note:
- Menu item availability depends on the super app's integrated modules.
- If you need to fully control the more menu, implement the
GRVMPMoreMenuDelegate
protocol. This interface provides the following capabilities:
- Control the visibility of menu items
- Add custom menu items
- Customize the appearance of menu items
- Handle click events of menu items
For implementation details, refer to Customize the more menu.
Typically, the super app implements either the
GRVMoreMenuInfoDelegate
protocol or theGRVMPMoreMenuDelegate
interface. If you implement both and conflicts occur, theGRVMPMoreMenuDelegate
implementation takes precedence.
Default user experience
The following image shows the default icon, title, and row layout of each menu item. Note that the favorite/unfavorite button does not have a default title, and the displayed text depends on your operational configurations.
Before you begin
To customize predefined more menu items, ensure that the integrated iOS IAPMiniProgram SDK is version 2.65.3 or later. For more information, see SDK release notes.
Procedure
To customize predefined more menu items, take the following two steps:
Step 1: Implement the GRVMoreMenuInfoDelegate
protocol
Define a class that implements the GRVMoreMenuInfoDelegate
protocol. Within the class, implement the getMoreMenuInfo
method to customize predefined more menu items. Refer to the following code for a sample implementation. For more information about the protocol and its defined method, refer to GRVMoreMenuInfoDelegate
.
class DemoMoreMenuInfoDelegate: NSObject, GRVMoreMenuInfoDelegate {
func getMoreMenuInfo(_ type:GRVMoreMenuItemType, status status:GRVMoreMenuItemStatus) -> GRVMoreMenuItemInfo {
let moreMenuItemInfo = GRVMoreMenuItemInfo.init();
// Customize icon, title, and layout based on the type and status parameters
return moreMenuItemInfo;
}
}
Step 2: Configure moreMenuInfoDelegate
After initializing the SDK, create an instance of GRVExtensionDelegate
and assign the implementation (for example, DemoMoreMenuInfoDelegate
in the sample) to the moreMenuInfoDelegate
property of the delegate's uiProvider
. Refer to the following sample configuration code:
let extensionDelegate = GRVExtensionDelegate()
extensionDelegate.uiProvider.moreMenuInfoDelegate = DemoMoreMenuInfoDelegate()
Structures
GRVMoreMenuInfoDelegate
protocol
The GRVMoreMenuInfoDelegate
protocol defines a method for the super app to customize predefined more menu items. The SDK then calls this method to retrieve the custom configuration for rendering the more menu. Refer to the following code for the protocol definition:
@protocol GRVMoreMenuInfoDelegate<NSObject>
@optional
- (GRVMoreMenuItemInfo *)getMoreMenuInfo:(GRVMoreMenuItemType)type status:(GRVMoreMenuItemStatus)status;
@end
Based on the definition, this interface provides the following methods:
Method Name | Description |
getMoreMenuInfo:status: | Called by the SDK to retrieve the custom configuration of a specific menu item. For more information, refer to |
getMoreMenuInfo:status:
method
Parameters
This method has the following input parameters:
Parameter | Data type | Required | Description |
type | GRVMoreMenuItemType | Yes | The specific menu item. Valid values are:
For more information, refer to the |
status | GRVMoreMenuItemStatus | Yes | The state of the favorite/unfavorite button. Valid values are:
For more information, refer to the Note: Apply this parameter value only when type is |
GRVMoreMenuItemType
definition
typedef NSString *GRVMoreMenuItemType NS_TYPED_EXTENSIBLE_ENUM;
FOUNDATION_EXPORT GRVMoreMenuItemType const GRVMoreMenuItemTypeCollect;
FOUNDATION_EXPORT GRVMoreMenuItemType const GRVMoreMenuItemTypeNotificationBox;
FOUNDATION_EXPORT GRVMoreMenuItemType const GRVMoreMenuItemTypeSubscribe;
FOUNDATION_EXPORT GRVMoreMenuItemType const GRVMoreMenuItemTypeFeedback;
FOUNDATION_EXPORT GRVMoreMenuItemType const GRVMoreMenuItemTypeSetting;
FOUNDATION_EXPORT GRVMoreMenuItemType const GRVMoreMenuItemTypeAbout;
FOUNDATION_EXPORT GRVMoreMenuItemType const GRVMoreMenuItemTypeShare;
FOUNDATION_EXPORT GRVMoreMenuItemType const GRVMoreMenuItemTypeReopen;
GRVMoreMenuItemStatus
definition
typedef NSString *GRVMoreMenuItemStatus NS_TYPED_EXTENSIBLE_ENUM;
FOUNDATION_EXPORT GRVMoreMenuItemStatus const GRVMoreMenuItemStatusCollectOn;
FOUNDATION_EXPORT GRVMoreMenuItemStatus const GRVMoreMenuItemStatusCollectOff;
Return value
The getMoreMenuInfo:status:
method returns an instance of the GRVMoreMenuItemInfo
object. Refer to the following code for the object definition:
typedef NS_ENUM(NSUInteger, GRVMoreMenuItemRow) {
GRVMoreMenuItemRowDefault = 0,
GRVMoreMenuItemRowOne = 1,
GRVMoreMenuItemRowTwo = 2,
};
@interface GRVMoreMenuItemInfo : NSObject
@property(nonatomic,copy) NSString *title;
@property(nonatomic,copy) NSString *iconPath;
@property(nonatomic,copy) NSString *darkIconPath;
@property(nonatomic,assign) GRVMoreMenuItemRow row;
@end
The object contains the following properties for the super app to customize the menu item:
Property | Data type | Required | Description |
title | NSString | Yes | The title of the menu item. |
iconPath | NSString | Yes | The icon path of the menu item for light mode. |
darkIconPath | NSString | Yes | The icon path of the menu item for dark mode. |
row | GRVMoreMenuItemRow | Yes | The row layout of the menu item. Valid values are:
Note:
|