4
votes

I recently packaged my app for MAC Store and was rejected. Below is the message sent to me by review team. When i testing using development mode everything works fine but I can't picture where i am getting something wrong. Any idea would be appreciated. App was built using Electron.

Design Preamble

The user interface of your app is not consistent with the macOS Human Interface Guidelines.

Specifically, we found that when the user closes the main application window there is no menu item to re-open it.

Next Steps

It would be appropriate for the app to implement a Window menu that lists the main window so it can be reopened, or provide similar functionality in another menu item. macOS Human Interface Guidelines state that "The menu bar [a]lways contains [a] Window menu".

Alternatively, if the application is a single-window app, it might be appropriate to save data and quit the app when the main window is closed.

For information on managing windows in macOS, please review the following sections in Apple Human Interface Guidelines:

The Menu Bar and Its Menus
The Window Menu
The File Menu
Clicking in the Dock
Window Behavior
Please evaluate how you can implement the appropriate changes, and resubmit your app for review.

3
I solved it by calling app.quit() on x button clicked. Apple doesn't want us to keep app on the dock when x button clicked.J O-bye Fsco

3 Answers

5
votes

The Problem is that after the Application is minimized by pressing the x button, there is no way for the user to open it again from the dock.

One way to fix this is to just terminate the Application when the x button is clicked.

I had the same issue and fixed it by adding this function in AppDelegate. This solution is for Swift 4.2

func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
    return true
}

Now the Application terminates, when the x button is clicked.

0
votes

If you are working with Xamarin, edit your AppDelegate.cs to create a menu to reopen the main window:

    public class AppDelegate : FormsApplicationDelegate
    {
        NSWindow window;

        public override NSWindow MainWindow
        {
            get
            {
                return window;
            }
        }

        public AppDelegate()
        {
            var style = NSWindowStyle.Closable | NSWindowStyle.Resizable | NSWindowStyle.Titled;
            var rect = new CoreGraphics.CGRect(100, 100, 1024, 768);

            window = new NSWindow(rect, style, NSBackingStore.Buffered, false);
            window.TitleVisibility = NSWindowTitleVisibility.Hidden;
        }

        private NSMenu MakeMainMenu()
        {
            // top bar app menu
            NSMenu menubar = new NSMenu();
            NSMenuItem appMenuItem = new NSMenuItem();
            menubar.AddItem(appMenuItem);

            NSMenu appMenu = new NSMenu();
            appMenuItem.Submenu = appMenu;

            // add separator
            NSMenuItem separator = NSMenuItem.SeparatorItem;
            appMenu.AddItem(separator);

            // add open menu item
            string openTitle = String.Format("Open {0}", "MyApp");
            var openMenuItem = new NSMenuItem(openTitle, "o", delegate
            {
                // Get new window
                window.MakeKeyAndOrderFront(this);
            });
            appMenu.AddItem(openMenuItem);

            // add quit menu item
            string quitTitle = String.Format("Quit {0}", "MyApp");
            var quitMenuItem = new NSMenuItem(quitTitle, "q", delegate
            {
                NSApplication.SharedApplication.Terminate(menubar);
            });
            appMenu.AddItem(quitMenuItem);
            return menubar;
        }

        public override void DidFinishLaunching(NSNotification notification)
        {
            // finally add menu
            NSApplication.SharedApplication.MainMenu = MakeMainMenu();
            // Insert code here to initialize your application
            Forms.Init();
            //Load Application
            LoadApplication(new App());
            //Did Finish Launching
            base.DidFinishLaunching(notification);
        }

        public override void WillTerminate(NSNotification notification)
        {
            // Insert code here to tear down your application
        }
    }

If you are workwing with Cocoa do the same but in the specific language.

Reopen the window with this instruction:

[window makeKeyAndOrderFront:self];
0
votes

For electron apps you can add this code to your index.js or main.js to resolve the issue:

app.on('window-all-closed', () => {
  app.quit();
});