Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
bf2166b6
E
engine
项目概览
sxychenjing
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
bf2166b6
编写于
5月 08, 2017
作者:
M
Mikkel Nygaard Ravn
提交者:
GitHub
5月 08, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
iOS plugin registry (#3645)
上级
b273d1ad
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
246 addition
and
14 deletion
+246
-14
shell/platform/darwin/ios/BUILD.gn
shell/platform/darwin/ios/BUILD.gn
+2
-0
shell/platform/darwin/ios/framework/Headers/Flutter.h
shell/platform/darwin/ios/framework/Headers/Flutter.h
+1
-0
shell/platform/darwin/ios/framework/Headers/FlutterAppDelegate.h
...latform/darwin/ios/framework/Headers/FlutterAppDelegate.h
+3
-1
shell/platform/darwin/ios/framework/Headers/FlutterPlugin.h
shell/platform/darwin/ios/framework/Headers/FlutterPlugin.h
+55
-0
shell/platform/darwin/ios/framework/Source/FlutterAppDelegate.mm
...latform/darwin/ios/framework/Source/FlutterAppDelegate.mm
+184
-13
travis/licenses_golden/licenses_flutter
travis/licenses_golden/licenses_flutter
+1
-0
未找到文件。
shell/platform/darwin/ios/BUILD.gn
浏览文件 @
bf2166b6
...
...
@@ -23,6 +23,7 @@ shared_library("flutter_framework_dylib") {
"framework/Headers/FlutterCodecs.h",
"framework/Headers/FlutterDartProject.h",
"framework/Headers/FlutterMacros.h",
"framework/Headers/FlutterPlugin.h",
"framework/Headers/FlutterViewController.h",
"framework/Source/FlutterAppDelegate.mm",
"framework/Source/FlutterChannels.mm",
...
...
@@ -163,6 +164,7 @@ copy("framework_headers") {
"framework/Headers/FlutterCodecs.h",
"framework/Headers/FlutterDartProject.h",
"framework/Headers/FlutterMacros.h",
"framework/Headers/FlutterPlugin.h",
"framework/Headers/FlutterViewController.h",
]
outputs = [
...
...
shell/platform/darwin/ios/framework/Headers/Flutter.h
浏览文件 @
bf2166b6
...
...
@@ -11,6 +11,7 @@
#include "FlutterCodecs.h"
#include "FlutterDartProject.h"
#include "FlutterMacros.h"
#include "FlutterPlugin.h"
#include "FlutterViewController.h"
#endif // FLUTTER_FLUTTER_H_
shell/platform/darwin/ios/framework/Headers/FlutterAppDelegate.h
浏览文件 @
bf2166b6
...
...
@@ -8,6 +8,7 @@
#import <UIKit/UIKit.h>
#include "FlutterMacros.h"
#include "FlutterPlugin.h"
/**
* UIApplicationDelegate subclass for simple apps that want default behavior.
...
...
@@ -23,7 +24,8 @@
* code as necessary from FlutterAppDelegate.mm.
*/
FLUTTER_EXPORT
@interface
FlutterAppDelegate
:
UIResponder
<
UIApplicationDelegate
>
@interface
FlutterAppDelegate
:
UIResponder
<
UIApplicationDelegate
,
FlutterPluginRegistry
>
@property
(
strong
,
nonatomic
)
UIWindow
*
window
;
...
...
shell/platform/darwin/ios/framework/Headers/FlutterPlugin.h
0 → 100644
浏览文件 @
bf2166b6
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_FLUTTERPLUGIN_H_
#define FLUTTER_FLUTTERPLUGIN_H_
#include "FlutterBinaryMessenger.h"
#include "FlutterChannels.h"
#include "FlutterCodecs.h"
NS_ASSUME_NONNULL_BEGIN
@protocol
FlutterPluginRegistrar
;
@protocol
FlutterPlugin
<
NSObject
>
@required
+
(
void
)
registerWithRegistrar
:(
NSObject
<
FlutterPluginRegistrar
>*
)
registrar
;
@optional
-
(
void
)
handleMethodCall
:(
FlutterMethodCall
*
)
call
result
:(
FlutterResult
)
result
;
-
(
BOOL
)
application
:(
UIApplication
*
)
application
didFinishLaunchingWithOptions
:(
NSDictionary
*
)
launchOptions
;
-
(
void
)
applicationDidBecomeActive
:(
UIApplication
*
)
application
;
-
(
void
)
applicationWillResignActive
:(
UIApplication
*
)
application
;
-
(
void
)
applicationDidEnterBackground
:(
UIApplication
*
)
application
;
-
(
void
)
applicationWillEnterForeground
:(
UIApplication
*
)
application
;
-
(
void
)
applicationWillTerminate
:(
UIApplication
*
)
application
;
-
(
void
)
application
:(
UIApplication
*
)
application
didRegisterUserNotificationSettings
:(
UIUserNotificationSettings
*
)
notificationSettings
;
-
(
void
)
application
:(
UIApplication
*
)
application
didRegisterForRemoteNotificationsWithDeviceToken
:(
NSData
*
)
deviceToken
;
-
(
BOOL
)
application
:(
UIApplication
*
)
application
didReceiveRemoteNotification
:(
NSDictionary
*
)
userInfo
fetchCompletionHandler
:(
void
(
^
)(
UIBackgroundFetchResult
result
))
completionHandler
;
-
(
BOOL
)
application
:(
UIApplication
*
)
application
openURL
:(
NSURL
*
)
url
options
:(
NSDictionary
<
UIApplicationOpenURLOptionsKey
,
id
>*
)
options
;
@end
@protocol
FlutterPluginRegistrar
<
NSObject
>
-
(
NSObject
<
FlutterBinaryMessenger
>*
)
messenger
;
-
(
void
)
publish
:(
NSObject
*
)
value
;
-
(
void
)
addMethodCallDelegate
:(
NSObject
<
FlutterPlugin
>*
)
delegate
channel
:(
FlutterMethodChannel
*
)
channel
;
-
(
void
)
addApplicationDelegate
:(
NSObject
<
FlutterPlugin
>*
)
delegate
;
@end
@protocol
FlutterPluginRegistry
<
NSObject
>
-
(
NSObject
<
FlutterPluginRegistrar
>*
)
registrarForPlugin
:(
NSString
*
)
pluginKey
;
-
(
BOOL
)
hasPlugin
:(
NSString
*
)
pluginKey
;
-
(
NSObject
*
)
valuePublishedByPlugin
:(
NSString
*
)
pluginKey
;
@end
NS_ASSUME_NONNULL_END
;
#endif // FLUTTER_FLUTTERPLUGIN_H_
shell/platform/darwin/ios/framework/Source/FlutterAppDelegate.mm
浏览文件 @
bf2166b6
...
...
@@ -6,10 +6,45 @@
#include "flutter/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h"
#include "lib/ftl/logging.h"
@interface
FlutterAppDelegate
()
@property
(
readonly
,
nonatomic
)
NSMutableArray
*
pluginDelegates
;
@property
(
readonly
,
nonatomic
)
NSMutableDictionary
*
pluginPublications
;
@end
@interface
FlutterAppDelegateRegistrar
:
NSObject
<
FlutterPluginRegistrar
>
-
(
instancetype
)
initWithPlugin
:(
NSString
*
)
pluginKey
appDelegate
:(
FlutterAppDelegate
*
)
delegate
;
@end
@implementation
FlutterAppDelegate
{
UIBackgroundTaskIdentifier
_debugBackgroundTask
;
}
-
(
instancetype
)
init
{
if
(
self
=
[
super
init
])
{
_pluginDelegates
=
[
NSMutableArray
new
];
_pluginPublications
=
[
NSMutableDictionary
new
];
}
return
self
;
}
-
(
void
)
dealloc
{
[
_pluginDelegates
release
];
[
_pluginPublications
release
];
[
super
dealloc
];
}
-
(
BOOL
)
application
:(
UIApplication
*
)
application
didFinishLaunchingWithOptions
:(
NSDictionary
*
)
launchOptions
{
for
(
id
<
FlutterPlugin
>
plugin
in
_pluginDelegates
)
{
if
([
plugin
respondsToSelector
:
_cmd
])
{
if
(
!
[
plugin
application
:
application
didFinishLaunchingWithOptions
:
launchOptions
])
{
return
NO
;
}
}
}
return
YES
;
}
// Returns the key window's rootViewController, if it's a FlutterViewController.
// Otherwise, returns nil.
-
(
FlutterViewController
*
)
rootFlutterViewController
{
...
...
@@ -29,25 +64,161 @@
}
}
-
(
void
)
applicationDidEnterBackground
:(
UIApplication
*
)
application
{
#if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG
-
(
void
)
applicationDidEnterBackground
:(
UIApplication
*
)
application
{
// The following keeps the Flutter session alive when the device screen locks
// in debug mode. It allows continued use of features like hot reload and
// in debug mode. It allows continued use of features like hot reload and
// taking screenshots once the device unlocks again.
//
// Note the name is not an identifier and multiple instances can exist.
_debugBackgroundTask
=
[
application
beginBackgroundTaskWithName
:
@"Flutter debug task"
expirationHandler:
^
{
FTL_LOG
(
WARNING
)
<<
"
\n
The OS has terminated the Flutter debug connection for being "
"inactive in the background for too long.
\n\n
"
"There are no errors with your Flutter application.
\n\n
"
"To reconnect, launch your application again via 'flutter run"
;
}];
// Note the name is not an identifier and multiple instances can exist.
_debugBackgroundTask
=
[
application
beginBackgroundTaskWithName:
@"Flutter debug task"
expirationHandler:
^
{
FTL_LOG
(
WARNING
)
<<
"
\n
The OS has terminated the Flutter debug connection for being "
"inactive in the background for too long.
\n\n
"
"There are no errors with your Flutter application.
\n\n
"
"To reconnect, launch your application again via 'flutter run"
;
}];
#endif // FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG
for
(
id
<
FlutterPlugin
>
plugin
in
_pluginDelegates
)
{
if
([
plugin
respondsToSelector
:
_cmd
])
{
[
plugin
applicationDidEnterBackground
:
application
];
}
}
}
-
(
void
)
applicationWillEnterForeground
:(
UIApplication
*
)
application
{
[
application
endBackgroundTask
:
_debugBackgroundTask
];
}
-
(
void
)
applicationWillEnterForeground
:(
UIApplication
*
)
application
{
#if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG
[
application
endBackgroundTask
:
_debugBackgroundTask
];
#endif // FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG
for
(
id
<
FlutterPlugin
>
plugin
in
_pluginDelegates
)
{
if
([
plugin
respondsToSelector
:
_cmd
])
{
[
plugin
applicationWillEnterForeground
:
application
];
}
}
}
-
(
void
)
applicationWillResignActive
:(
UIApplication
*
)
application
{
for
(
id
<
FlutterPlugin
>
plugin
in
_pluginDelegates
)
{
if
([
plugin
respondsToSelector
:
_cmd
])
{
[
plugin
applicationWillResignActive
:
application
];
}
}
}
-
(
void
)
applicationDidBecomeActive
:(
UIApplication
*
)
application
{
for
(
id
<
FlutterPlugin
>
plugin
in
_pluginDelegates
)
{
if
([
plugin
respondsToSelector
:
_cmd
])
{
[
plugin
applicationDidBecomeActive
:
application
];
}
}
}
-
(
void
)
applicationWillTerminate
:(
UIApplication
*
)
application
{
for
(
id
<
FlutterPlugin
>
plugin
in
_pluginDelegates
)
{
if
([
plugin
respondsToSelector
:
_cmd
])
{
[
plugin
applicationWillTerminate
:
application
];
}
}
}
-
(
void
)
application
:(
UIApplication
*
)
application
didRegisterUserNotificationSettings
:(
UIUserNotificationSettings
*
)
notificationSettings
{
for
(
id
<
FlutterPlugin
>
plugin
in
_pluginDelegates
)
{
if
([
plugin
respondsToSelector
:
_cmd
])
{
[
plugin
application
:
application
didRegisterUserNotificationSettings
:
notificationSettings
];
}
}
}
-
(
void
)
application
:(
UIApplication
*
)
application
didRegisterForRemoteNotificationsWithDeviceToken
:(
NSData
*
)
deviceToken
{
for
(
id
<
FlutterPlugin
>
plugin
in
_pluginDelegates
)
{
if
([
plugin
respondsToSelector
:
_cmd
])
{
[
plugin
application
:
application
didRegisterForRemoteNotificationsWithDeviceToken
:
deviceToken
];
}
}
}
-
(
void
)
application
:(
UIApplication
*
)
application
didReceiveRemoteNotification
:(
NSDictionary
*
)
userInfo
fetchCompletionHandler
:(
void
(
^
)(
UIBackgroundFetchResult
result
))
completionHandler
{
for
(
id
<
FlutterPlugin
>
plugin
in
_pluginDelegates
)
{
if
([
plugin
respondsToSelector
:
_cmd
])
{
if
([
plugin
application
:
application
didReceiveRemoteNotification:
userInfo
fetchCompletionHandler:
completionHandler
])
{
return
;
}
}
}
}
-
(
BOOL
)
application
:(
UIApplication
*
)
application
openURL
:(
NSURL
*
)
url
options
:(
NSDictionary
<
UIApplicationOpenURLOptionsKey
,
id
>*
)
options
{
for
(
id
<
FlutterPlugin
>
plugin
in
_pluginDelegates
)
{
if
([
plugin
respondsToSelector
:
_cmd
])
{
if
([
plugin
application
:
application
openURL
:
url
options
:
options
])
{
return
YES
;
}
}
}
return
NO
;
}
-
(
NSObject
<
FlutterPluginRegistrar
>*
)
registrarForPlugin
:(
NSString
*
)
pluginKey
{
NSAssert
(
self
.
pluginPublications
[
pluginKey
]
==
nil
,
@"Duplicate plugin key: %@"
,
pluginKey
);
self
.
pluginPublications
[
pluginKey
]
=
[
NSNull
null
];
return
[[[
FlutterAppDelegateRegistrar
alloc
]
initWithPlugin
:
pluginKey
appDelegate
:
self
]
autorelease
];
}
-
(
BOOL
)
hasPlugin
:(
NSString
*
)
pluginKey
{
return
_pluginPublications
[
pluginKey
]
!=
nil
;
}
-
(
NSObject
*
)
valuePublishedByPlugin
:(
NSString
*
)
pluginKey
{
return
_pluginPublications
[
pluginKey
];
}
@end
@implementation
FlutterAppDelegateRegistrar
{
NSString
*
_pluginKey
;
FlutterAppDelegate
*
_appDelegate
;
}
-
(
instancetype
)
initWithPlugin
:(
NSString
*
)
pluginKey
appDelegate
:(
FlutterAppDelegate
*
)
appDelegate
{
self
=
[
super
init
];
NSAssert
(
self
,
@"Super init cannot be nil"
);
_pluginKey
=
[
pluginKey
retain
];
_appDelegate
=
[
appDelegate
retain
];
return
self
;
}
-
(
void
)
dealloc
{
[
_pluginKey
release
];
[
_appDelegate
release
];
[
super
dealloc
];
}
-
(
NSObject
<
FlutterBinaryMessenger
>*
)
messenger
{
return
(
FlutterViewController
*
)
_appDelegate
.
window
.
rootViewController
;
}
-
(
void
)
publish
:(
NSObject
*
)
value
{
_appDelegate
.
pluginPublications
[
_pluginKey
]
=
value
;
}
-
(
void
)
addMethodCallDelegate
:(
NSObject
<
FlutterPlugin
>*
)
delegate
channel
:(
FlutterMethodChannel
*
)
channel
{
[
channel
setMethodCallHandler
:
^
(
FlutterMethodCall
*
call
,
FlutterResult
result
)
{
[
delegate
handleMethodCall
:
call
result
:
result
];
}];
}
-
(
void
)
addApplicationDelegate
:(
NSObject
<
FlutterPlugin
>*
)
delegate
{
[
_appDelegate
.
pluginDelegates
addObject
:
delegate
];
}
@end
travis/licenses_golden/licenses_flutter
浏览文件 @
bf2166b6
...
...
@@ -1437,6 +1437,7 @@ FILE: ../../../flutter/shell/platform/android/platform_view_android_jni.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Headers/FlutterBinaryMessenger.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Headers/FlutterChannels.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Headers/FlutterCodecs.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Headers/FlutterPlugin.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterChannels.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterCodecs.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterStandardCodec.mm
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录