This repository has been archived by the owner on May 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
RAHostManager.xm
57 lines (46 loc) · 1.72 KB
/
RAHostManager.xm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#import "RAHostManager.h"
#import "RACompatibilitySystem.h"
@implementation RAHostManager
+(UIView*) systemHostViewForApplication:(SBApplication*)app
{
if (!app)
return nil;
if ([app respondsToSelector:@selector(mainScene)]) // iOS 8
return MSHookIvar<UIView*>(app.mainScene.contextHostManager, "_hostView");
else if ([app respondsToSelector:@selector(mainScreenContextHostManager)])
return MSHookIvar<UIView*>([app mainScreenContextHostManager], "_hostView");
[RACompatibilitySystem showWarning:@"Unable to find valid method for accessing system context host views"];
return nil;
}
+(UIView*) enabledHostViewForApplication:(SBApplication*)app
{
if (!app)
return nil;
if ([app respondsToSelector:@selector(mainScene)])
{
FBScene *scene = [app mainScene];
FBWindowContextHostManager *contextHostManager = [scene contextHostManager];
FBSMutableSceneSettings *settings = [[scene mutableSettings] mutableCopy];
if (!settings)
return nil;
SET_BACKGROUNDED(settings, NO);
[scene _applyMutableSettings:settings withTransitionContext:nil completion:nil];
[contextHostManager enableHostingForRequester:@"reachapp" orderFront:YES];
return [contextHostManager hostViewForRequester:@"reachapp" enableAndOrderFront:YES];
}
[RACompatibilitySystem showWarning:@"Unable to find valid method for accessing context host views"];
return nil;
}
+(NSObject*) hostManagerForApp:(SBApplication*)app
{
if (!app)
return nil;
if ([app respondsToSelector:@selector(mainScene)])
{
FBScene *scene = [app mainScene];
return (NSObject*)[scene contextHostManager];
}
[RACompatibilitySystem showWarning:@"Unable to find valid method for accessing context host view managers"];
return nil;
}
@end