Flutter Engine
FlutterAppDelegate.mm
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #import "flutter/shell/platform/darwin/macos/framework/Headers/FlutterAppDelegate.h"
6 
7 @interface FlutterAppDelegate ()
8 
9 /**
10  * Returns the display name of the application as set in the Info.plist.
11  */
12 - (NSString*)applicationName;
13 
14 @end
15 
16 @implementation FlutterAppDelegate
17 
18 // TODO(stuartmorgan): Implement application lifecycle forwarding to plugins here, as is done
19 // on iOS. Currently macOS plugins don't have access to lifecycle messages.
20 
21 - (void)applicationWillFinishLaunching:(NSNotification*)notification {
22  // Update UI elements to match the application name.
23  NSString* applicationName = [self applicationName];
24  _mainFlutterWindow.title = applicationName;
25  for (NSMenuItem* menuItem in _applicationMenu.itemArray) {
26  menuItem.title = [menuItem.title stringByReplacingOccurrencesOfString:@"APP_NAME"
27  withString:applicationName];
28  }
29 }
30 
31 #pragma mark Private Methods
32 
33 - (NSString*)applicationName {
34  NSString* applicationName =
35  [NSBundle.mainBundle objectForInfoDictionaryKey:@"CFBundleDisplayName"];
36  if (!applicationName) {
37  applicationName = [NSBundle.mainBundle objectForInfoDictionaryKey:@"CFBundleName"];
38  }
39  return applicationName;
40 }
41 
42 @end
NSString * applicationName()