| Flutter iOS Embedder |

FlutterSharedApplication.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/ios/framework/Source/FlutterSharedApplication.h"
6
7 #include "flutter/fml/logging.h"
8 #import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h"
9
10 FLUTTER_ASSERT_ARC
11
12 @implementation FlutterSharedApplication
13
14 + (BOOL)isAppExtension {
15 NSDictionary* nsExtension = [NSBundle.mainBundle objectForInfoDictionaryKey:@"NSExtension"];
16 return [nsExtension isKindOfClass:[NSDictionary class]];
17 }
18
19 + (BOOL)isAvailable {
20 // If the bundle is an App Extension, the application is not available.
21 // Therefore access to `UIApplication.sharedApplication` is not allowed.
22 return !FlutterSharedApplication.isAppExtension;
23 }
24
25 + (UIApplication*)application {
26 if (FlutterSharedApplication.isAvailable) {
27 return FlutterSharedApplication.sharedApplication;
28 }
29 return nil;
30 }
31
32 + (UIApplication*)
33 sharedApplication NS_EXTENSION_UNAVAILABLE_IOS("Accesses unavailable sharedApplication.") {
34 return UIApplication.sharedApplication;
35 }
36
37 @end
FlutterMacros.h
FlutterSharedApplication.h
FlutterSharedApplication
Definition: FlutterSharedApplication.h:11
FlutterSharedApplication::application
UIApplication * application
Definition: FlutterSharedApplication.h:25
FlutterSharedApplication::isAppExtension
BOOL isAppExtension
Definition: FlutterSharedApplication.h:15
FlutterSharedApplication::isAvailable
BOOL isAvailable
Definition: FlutterSharedApplication.h:20
FLUTTER_ASSERT_ARC
Definition: FlutterChannelKeyResponder.mm:13