Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
49b6de8c
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,发现更多精彩内容 >>
未验证
提交
49b6de8c
编写于
5月 30, 2019
作者:
C
Chris Yang
提交者:
GitHub
5月 30, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Dynamically add certain iOS AppDelegate methods. (#8843)
上级
58eff77e
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
102 addition
and
14 deletion
+102
-14
ci/licenses_golden/licenses_flutter
ci/licenses_golden/licenses_flutter
+1
-0
shell/platform/darwin/ios/framework/Headers/FlutterPluginAppLifeCycleDelegate.h
...ios/framework/Headers/FlutterPluginAppLifeCycleDelegate.h
+1
-0
shell/platform/darwin/ios/framework/Source/FlutterAppDelegate.mm
...latform/darwin/ios/framework/Source/FlutterAppDelegate.mm
+57
-14
shell/platform/darwin/ios/framework/Source/FlutterPluginAppLifeCycleDelegate.mm
...ios/framework/Source/FlutterPluginAppLifeCycleDelegate.mm
+25
-0
shell/platform/darwin/ios/framework/Source/FlutterPluginAppLifeCycleDelegate_internal.h
...ework/Source/FlutterPluginAppLifeCycleDelegate_internal.h
+18
-0
未找到文件。
ci/licenses_golden/licenses_flutter
浏览文件 @
49b6de8c
...
...
@@ -677,6 +677,7 @@ FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatfor
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterPluginAppLifeCycleDelegate.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterPluginAppLifeCycleDelegate_internal.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterStandardCodec.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterStandardCodec_Internal.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputDelegate.h
...
...
shell/platform/darwin/ios/framework/Headers/FlutterPluginAppLifeCycleDelegate.h
浏览文件 @
49b6de8c
...
...
@@ -14,6 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
*/
FLUTTER_EXPORT
@interface
FlutterPluginAppLifeCycleDelegate
:
NSObject
/**
* Registers `delegate` to receive life cycle callbacks via this FlutterPluginAppLifecycleDelegate
* as long as it is alive.
...
...
shell/platform/darwin/ios/framework/Source/FlutterAppDelegate.mm
浏览文件 @
49b6de8c
...
...
@@ -3,8 +3,14 @@
// found in the LICENSE file.
#include "flutter/shell/platform/darwin/ios/framework/Headers/FlutterAppDelegate.h"
#include "flutter/fml/logging.h"
#include "flutter/shell/platform/darwin/ios/framework/Headers/FlutterPluginAppLifeCycleDelegate.h"
#include "flutter/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h"
#include "flutter/shell/platform/darwin/ios/framework/Source/FlutterPluginAppLifeCycleDelegate_internal.h"
static
NSString
*
kUIBackgroundMode
=
@"UIBackgroundModes"
;
static
NSString
*
kRemoteNotificationCapabitiliy
=
@"remote-notification"
;
static
NSString
*
kBackgroundFetchCapatibility
=
@"fetch"
;
@implementation
FlutterAppDelegate
{
FlutterPluginAppLifeCycleDelegate
*
_lifeCycleDelegate
;
...
...
@@ -86,14 +92,6 @@
didRegisterForRemoteNotificationsWithDeviceToken:
deviceToken
];
}
-
(
void
)
application
:(
UIApplication
*
)
application
didReceiveRemoteNotification
:(
NSDictionary
*
)
userInfo
fetchCompletionHandler
:(
void
(
^
)(
UIBackgroundFetchResult
result
))
completionHandler
{
[
_lifeCycleDelegate
application
:
application
didReceiveRemoteNotification:
userInfo
fetchCompletionHandler:
completionHandler
];
}
-
(
void
)
application
:(
UIApplication
*
)
application
didReceiveLocalNotification
:(
UILocalNotification
*
)
notification
{
[
_lifeCycleDelegate
application
:
application
didReceiveLocalNotification
:
notification
];
...
...
@@ -147,11 +145,6 @@
completionHandler:
completionHandler
];
}
-
(
void
)
application
:(
UIApplication
*
)
application
performFetchWithCompletionHandler
:(
void
(
^
)(
UIBackgroundFetchResult
result
))
completionHandler
{
[
_lifeCycleDelegate
application
:
application
performFetchWithCompletionHandler
:
completionHandler
];
}
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 120000
-
(
BOOL
)
application
:(
UIApplication
*
)
application
continueUserActivity
:(
NSUserActivity
*
)
userActivity
...
...
@@ -195,10 +188,60 @@
return
nil
;
}
#pragma mark -
FlutterAppLifeCycleProvider methods
#pragma mark -
Selectors handling
-
(
void
)
addApplicationLifeCycleDelegate
:
(
NSObject
<
FlutterPlugin
>*
)
delegate
{
[
_lifeCycleDelegate
addDelegate
:
delegate
];
}
#pragma mark - UIApplicationDelegate method dynamic implementation
-
(
BOOL
)
respondsToSelector
:
(
SEL
)
selector
{
if
([
_lifeCycleDelegate
isSelectorAddedDynamically
:
selector
])
{
return
[
self
delegateRespondsSelectorToPlugins
:
selector
];
}
return
[
super
respondsToSelector
:
selector
];
}
-
(
BOOL
)
delegateRespondsSelectorToPlugins
:
(
SEL
)
selector
{
if
([
_lifeCycleDelegate
hasPluginThatRespondsToSelector
:
selector
])
{
return
[
_lifeCycleDelegate
respondsToSelector
:
selector
];
}
else
{
return
NO
;
}
}
-
(
id
)
forwardingTargetForSelector
:
(
SEL
)
aSelector
{
if
([
_lifeCycleDelegate
isSelectorAddedDynamically
:
aSelector
])
{
[
self
logCapabilityConfigurationWarningIfNeeded
:
aSelector
];
return
_lifeCycleDelegate
;
}
return
[
super
forwardingTargetForSelector
:
aSelector
];
}
// Mimic the logging from Apple when the capability is not set for the selectors.
// However the difference is that Apple logs these message when the app launches, we only
// log it when the method is invoked. We can possibly also log it when the app launches, but
// it will cause an additional scan over all the plugins.
-
(
void
)
logCapabilityConfigurationWarningIfNeeded
:
(
SEL
)
selector
{
NSArray
*
backgroundModesArray
=
[[
NSBundle
mainBundle
]
objectForInfoDictionaryKey
:
kUIBackgroundMode
];
NSSet
*
backgroundModesSet
=
[[[
NSSet
alloc
]
initWithArray
:
backgroundModesArray
]
autorelease
];
if
(
selector
==
@selector
(
application
:
didReceiveRemoteNotification
:
fetchCompletionHandler
:
))
{
if
(
!
[
backgroundModesSet
containsObject
:
kRemoteNotificationCapabitiliy
])
{
NSLog
(
@"You've implemented -[<UIApplicationDelegate> "
@"application:didReceiveRemoteNotification:fetchCompletionHandler:], but you still need "
@"to add
\"
remote-notification
\"
to the list of your supported UIBackgroundModes in your "
@"Info.plist."
);
}
}
else
if
(
selector
==
@selector
(
application
:
performFetchWithCompletionHandler
:
))
{
if
(
!
[
backgroundModesSet
containsObject
:
kBackgroundFetchCapatibility
])
{
NSLog
(
@"You've implemented -[<UIApplicationDelegate> "
@"application:performFetchWithCompletionHandler:], but you still need to add
\"
fetch
\"
"
@"to the list of your supported UIBackgroundModes in your Info.plist."
);
}
}
}
@end
shell/platform/darwin/ios/framework/Source/FlutterPluginAppLifeCycleDelegate.mm
浏览文件 @
49b6de8c
...
...
@@ -11,6 +11,10 @@
static
const
char
*
kCallbackCacheSubDir
=
"Library/Caches/"
;
static
const
SEL
selectorsHandledByPlugins
[]
=
{
@selector
(
application
:
didReceiveRemoteNotification
:
fetchCompletionHandler
:
),
@selector
(
application
:
performFetchWithCompletionHandler
:
)};
@implementation
FlutterPluginAppLifeCycleDelegate
{
UIBackgroundTaskIdentifier
_debugBackgroundTask
;
...
...
@@ -36,6 +40,27 @@ static BOOL isPowerOfTwo(NSUInteger x) {
return
x
!=
0
&&
(
x
&
(
x
-
1
))
==
0
;
}
-
(
BOOL
)
isSelectorAddedDynamically
:(
SEL
)
selector
{
for
(
const
SEL
&
aSelector
:
selectorsHandledByPlugins
)
{
if
(
selector
==
aSelector
)
{
return
YES
;
}
}
return
NO
;
}
-
(
BOOL
)
hasPluginThatRespondsToSelector
:(
SEL
)
selector
{
for
(
id
<
FlutterPlugin
>
plugin
in
[
_pluginDelegates
allObjects
])
{
if
(
!
plugin
)
{
continue
;
}
if
([
plugin
respondsToSelector
:
selector
])
{
return
YES
;
}
}
return
NO
;
}
-
(
void
)
addDelegate
:(
NSObject
<
FlutterPlugin
>*
)
delegate
{
[
_pluginDelegates
addPointer
:(
__bridge
void
*
)
delegate
];
if
(
isPowerOfTwo
([
_pluginDelegates
count
]))
{
...
...
shell/platform/darwin/ios/framework/Source/FlutterPluginAppLifeCycleDelegate_internal.h
0 → 100644
浏览文件 @
49b6de8c
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@interface
FlutterPluginAppLifeCycleDelegate
()
/**
* Check whether the selector should be handled dynamically.
*/
-
(
BOOL
)
isSelectorAddedDynamically
:(
SEL
)
selector
;
/**
* Check whether there is at least one plugin responds to the selector.
*/
-
(
BOOL
)
hasPluginThatRespondsToSelector
:(
SEL
)
selector
;
@end
;
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录