Proyectos de Subversion Iphone Microlearning

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
/*
2
 * Copyright 2018 Google
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *      http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
 
17
#import <TargetConditionals.h>
18
#if TARGET_OS_IOS
19
 
20
#import "FirebaseInAppMessaging/Sources/DefaultUI/Banner/FIRIAMBannerViewUIWindow.h"
21
#import "FirebaseInAppMessaging/Sources/DefaultUI/FIRIAMRenderingWindowHelper.h"
22
 
23
@implementation FIRIAMRenderingWindowHelper
24
 
25
+ (UIWindow *)windowForBlockingView {
26
  static UIWindow *UIWindowForModal;
27
  static dispatch_once_t onceToken;
28
 
29
  dispatch_once(&onceToken, ^{
30
#if defined(__IPHONE_13_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
31
    if (@available(iOS 13.0, tvOS 13.0, *)) {
32
      UIWindowForModal = [[self class] iOS13PlusWindow];
33
    } else {
34
#endif  // defined(__IPHONE_13_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
35
      UIWindowForModal = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
36
#if defined(__IPHONE_13_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
37
    }
38
#endif  // defined(__IPHONE_13_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
39
    UIWindowForModal.windowLevel = UIWindowLevelNormal;
40
  });
41
  return UIWindowForModal;
42
}
43
 
44
+ (UIWindow *)windowForNonBlockingView {
45
  static UIWindow *UIWindowForBanner;
46
  static dispatch_once_t onceToken;
47
 
48
  dispatch_once(&onceToken, ^{
49
#if defined(__IPHONE_13_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
50
    if (@available(iOS 13.0, tvOS 13.0, *)) {
51
      UIWindowForBanner = [[self class] iOS13PlusBannerWindow];
52
    } else {
53
#endif  // defined(__IPHONE_13_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
54
      UIWindowForBanner =
55
          [[FIRIAMBannerViewUIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
56
#if defined(__IPHONE_13_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
57
    }
58
#endif
59
    UIWindowForBanner.windowLevel = UIWindowLevelNormal;
60
  });
61
 
62
  return UIWindowForBanner;
63
}
64
 
65
#if defined(__IPHONE_13_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
66
+ (UIWindowScene *)foregroundedScene API_AVAILABLE(ios(13.0)) {
67
  for (UIWindowScene *connectedScene in [UIApplication sharedApplication].connectedScenes) {
68
    if (connectedScene.activationState == UISceneActivationStateForegroundActive) {
69
      return connectedScene;
70
    }
71
  }
72
  return nil;
73
}
74
 
75
+ (UIWindow *)iOS13PlusWindow API_AVAILABLE(ios(13.0)) {
76
  UIWindowScene *foregroundedScene = [[self class] foregroundedScene];
77
  if (foregroundedScene.delegate) {
78
    return [[UIWindow alloc] initWithWindowScene:foregroundedScene];
79
  } else {
80
    return [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
81
  }
82
}
83
 
84
+ (FIRIAMBannerViewUIWindow *)iOS13PlusBannerWindow API_AVAILABLE(ios(13.0)) {
85
  UIWindowScene *foregroundedScene = [[self class] foregroundedScene];
86
  if (foregroundedScene.delegate) {
87
    return [[FIRIAMBannerViewUIWindow alloc] initWithWindowScene:foregroundedScene];
88
  } else {
89
    return [[FIRIAMBannerViewUIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
90
  }
91
}
92
 
93
#endif
94
@end
95
 
96
#endif  // TARGET_OS_IOS