diff --git a/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FlutterViewController.mm b/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FlutterViewController.mm index 7ef1636ace..bb928da63a 100644 --- a/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FlutterViewController.mm +++ b/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FlutterViewController.mm @@ -146,7 +146,7 @@ struct KeyboardState { - (void)sendInitialSettings; /** - * Responsds to updates in the user settings and passes this data to the engine. + * Responds to updates in the user settings and passes this data to the engine. */ - (void)onSettingsChanged:(NSNotification*)notification; @@ -155,6 +155,12 @@ struct KeyboardState { */ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result; +/** + * Plays a system sound. |soundType| specifies which system sound to play. Valid + * values can be found in the SystemSoundType enum in the services SDK package. + */ +- (void)playSystemSound:(NSString*)soundType; + /** * Reads the data from the clipboard. |format| specifies the media type of the * data to obtain. @@ -490,6 +496,9 @@ static void CommonInit(FlutterViewController* controller) { if ([call.method isEqualToString:@"SystemNavigator.pop"]) { [NSApp terminate:self]; result(nil); + } else if ([call.method isEqualToString:@"SystemSound.play"]) { + [self playSystemSound:call.arguments]; + result(nil); } else if ([call.method isEqualToString:@"Clipboard.getData"]) { result([self getClipboardData:call.arguments]); } else if ([call.method isEqualToString:@"Clipboard.setData"]) { @@ -500,6 +509,12 @@ static void CommonInit(FlutterViewController* controller) { } } +- (void)playSystemSound:(NSString*)soundType { + if ([soundType isEqualToString:@"SystemSoundType.alert"]) { + NSBeep(); + } +} + - (NSDictionary*)getClipboardData:(NSString*)format { NSPasteboard* pasteboard = [NSPasteboard generalPasteboard]; if ([format isEqualToString:@(kTextPlainFormat)]) {