Antom, leading provider of tailored payment solutionsAntom, leading provider of tailored payment solutions

Customize the more menu for mini program

When a user clicks the more menu in the mini program, Griver AppContainer shows a panel that contains lots of menus. The menu items can be customized by GRVMPMoreMenuDelegate.

copy
@protocol GRVMPMoreMenuDelegate <NSObject>

@required
- (NSArray <GRVMPMoreMenuItem *>*)getMenuList:(NSString *)appId;

@end

You can return a list of menus to Griver AppContainer, then Griver AppContainer renders the menu in the panel.

The menu item contains the following properties.

Property

Type

Nullable

Description

identifier

String

No

The id of the menu, which should be unique among all menus.

title

String

No

The title of the menu, which is displayed in the panel.

icon

UIImage

Yes

The icon of the menu item, which is displayed in the panel.

row

NSInteger

NO

The row of the menu, which supports 1 and 2. The row 1 menu is in the first row and 2 in the second row. If you do not set this value, it will not be shown.

clickMenuItemAction

GRVMPMoreMenuActionBlock

Yes

Menu action for clicking the menu item. It should not be null.

Here is the definition of GRVMPMoreMenuActionBlock:

copy
typedef void (^GRVMPMoreMenuActionBlock)(GRVMoreMenuContext *context);

And GRVMPMoreMenuItem has one method for deciding whether to show it in the menu panel:

copy
/**
 Decide whether the menu item can be showed in the mini program app.
 
 Default value is YES.
 
 @param appId NSString represent the mini program app , which shows the more menu items.
 @return BOOL,  YES for  showing  the menu item, No for not showing the menu item. 
 */
- (BOOL)canShowForMPAppId:(NSString *)appId;

By default, Griver AppContainer shows the default menu list in the menu panel. Default more menu list includes Share, Setting, Feedback, and About. Feedback is only shown when you implemented GRVMPFeedbackDelegate.

copy
@interface GRVMoreMenuUtil : NSObject

/**
 Default mini program more menu lists.
 
 @return NSArray<GRVMPMoreMenuItem *>
 */
+(NSArray<GRVMPMoreMenuItem *> * _Nullable)defaultMPMoreMenuItemsWithAppId:(NSString *)appId ;

@end

So to add or remove the default menus, implement the GRVMPMoreMenuDelegate.

copy
@protocol GRVMPMoreMenuDelegate <NSObject>

@required
// When you implemented the GRVMPMoreMenuDelegate, and if the getMenuList method return a empty list, more menu panel will show empty more menu list.
- (NSArray <GRVMPMoreMenuItem *>*)getMenuList:(NSString *)appId;

@end

Implement the GRVMPMoreMenuDelegate and your own extension, and then configure to Griver AppContainer as follows. Then you can see your customized menus in the mini program.

copy
// let extensionDelegate = GRVExtensionDelegate() 
extensionDelegate.uiProvider.moreMenuDelegate = MPMoreMenuDelegateImpl()

Use feedback capacity

The behavior of the Feedback menu is to open another mini program to collect users' feedback. And this mini program is developed by Ant team. It will be published to your app if you want to integrate this capacity. And Griver AppContainer cannot know the appId of the feedback mini program, so you need to tell the Griver AppContainer what the appId is, otherwise the Feedback menu cannot be displayed in the panel.

You can implement the following delegate to pass the feedback mini program id to Griver AppContainer.

copy
@protocol GRVMPFeedbackDelegate <NSObject>

@required
- (NSString *)getFeedbackMiniProgramId:(NSString *)appId;

@end

Implement the extension and configure it to Griver AppContainer, then you can use the feedback capacity and improve your mini program continuously based on users' feedback.

copy
// let extensionDelegate = GRVExtensionDelegate() 
extensionDelegate.uiProvider.feedbackDelegate = DemoGRVMPFeedbackDelegateImpl()

Demo show

How to manage your share item list with the default share items?

copy
- (NSArray <GRVMPMoreMenuItem *>*)getMenuList:(NSString *)appId {
     NSMutableArray *finalMenuList = [[NSMutableArray alloc] init];
    
    // default more menu list include Share, Setting, Feedback and About,and Feedback only can be showed when you have implemented GRVMPFeedbackDelegate.
    NSArray *defalutMenuList = [GRVMoreMenuUtil defaultMPMoreMenuItemsWithAppId:appId];
    
    // add Share item from default menu list for your menu list.
    for(GRVMPMoreMenuItem * menuItem in defalutMenuList) {
       if([menuItem.identifier isEqualToString:@"Share"]) {
          [finalMenuList addObject:menuItem];
       }
    }
   
    // add another menu item
    GRVMPMoreMenuItem *item = [[GRVAboutMenuItem alloc] initWithTitle:title icon:icon identifier:identifier row:row clickMenuItemAction:clickMenuItemAction];
    [finalMenuList addObject:item];
    
    return finalMenuList;
}