@@ -55,24 +55,28 @@ - (NSDictionary *)constantsToExport
55
55
reject (@" error" , @" Not supported multiple scenes" , nil );
56
56
return ;
57
57
}
58
- if (options[@" userInfo" ] && ![options[@" userInfo" ] isKindOfClass: [NSDictionary class ]]) {
59
- reject (@" error" , @" options.userInfo must be object" , nil );
60
- return ;
61
- }
62
- NSMutableDictionary *userInfo = [options[@" userInfo" ] mutableCopy ];
63
- if (!userInfo) userInfo = [NSMutableDictionary new ];
64
- if (options[@" windowBackgroundColor" ]) {
65
- userInfo[@" windowBackgroundColor" ] = options[@" windowBackgroundColor" ];
58
+ if (@available (iOS 13.0 , tvOS 13.0 , *)) {
59
+ if (options[@" userInfo" ] && ![options[@" userInfo" ] isKindOfClass: [NSDictionary class ]]) {
60
+ reject (@" error" , @" options.userInfo must be object" , nil );
61
+ return ;
62
+ }
63
+ NSMutableDictionary *userInfo = [options[@" userInfo" ] mutableCopy ];
64
+ if (!userInfo) userInfo = [NSMutableDictionary new ];
65
+ if (options[@" windowBackgroundColor" ]) {
66
+ userInfo[@" windowBackgroundColor" ] = options[@" windowBackgroundColor" ];
67
+ }
68
+ NSUserActivity *userActivity = [[NSUserActivity alloc ] initWithActivityType: RN_EXTERNAL_SCENE_TYPE_CREATE];
69
+ userActivity.userInfo = userInfo;
70
+ [UIApplication.sharedApplication
71
+ requestSceneSessionActivation: nil
72
+ userActivity: userActivity
73
+ options: nil
74
+ errorHandler: nil // NOTE: No completion handler here so it is hard to use promise
75
+ ];
76
+ resolve (@YES );
77
+ } else {
78
+ reject (@" error" , @" Required iOS 13.0 or above" , nil );
66
79
}
67
- NSUserActivity *userActivity = [[NSUserActivity alloc ] initWithActivityType: RN_EXTERNAL_SCENE_TYPE_CREATE];
68
- userActivity.userInfo = userInfo;
69
- [UIApplication.sharedApplication
70
- requestSceneSessionActivation: nil
71
- userActivity: userActivity
72
- options: nil
73
- errorHandler: nil // NOTE: No completion handler here so it is hard to use promise
74
- ];
75
- resolve (@YES );
76
80
});
77
81
}
78
82
@@ -82,19 +86,23 @@ - (NSDictionary *)constantsToExport
82
86
reject (@" error" , @" Not supported multiple scenes" , nil );
83
87
return ;
84
88
}
85
- NSSet *scenes = [UIApplication sharedApplication ].connectedScenes ;
86
- for (UIWindowScene* scene in scenes) {
87
- if ([scene.session.persistentIdentifier isEqual: sceneId]) {
88
- [UIApplication.sharedApplication
89
- requestSceneSessionDestruction: scene.session
90
- options: nil
91
- errorHandler: nil // NOTE: No completion handler here so it is hard to use promise
92
- ];
93
- resolve (@YES );
94
- return ;
89
+ if (@available (iOS 13.0 , tvOS 13.0 , *)) {
90
+ NSSet *scenes = [UIApplication sharedApplication ].connectedScenes ;
91
+ for (UIWindowScene* scene in scenes) {
92
+ if ([scene.session.persistentIdentifier isEqual: sceneId]) {
93
+ [UIApplication.sharedApplication
94
+ requestSceneSessionDestruction: scene.session
95
+ options: nil
96
+ errorHandler: nil // NOTE: No completion handler here so it is hard to use promise
97
+ ];
98
+ resolve (@YES );
99
+ return ;
100
+ }
95
101
}
102
+ reject (@" error" , @" No scene found" , nil );
103
+ } else {
104
+ reject (@" error" , @" Required iOS 13.0 or above" , nil );
96
105
}
97
- reject (@" error" , @" No scene found" , nil );
98
106
});
99
107
}
100
108
@@ -104,7 +112,12 @@ - (NSDictionary *)constantsToExport
104
112
reject (@" error" , @" Not supported multiple scenes" , nil );
105
113
return ;
106
114
}
107
- resolve (@([RNExternalAppDelegateUtil isMainSceneActive ]));
115
+
116
+ if (@available (iOS 13.0 , tvOS 13.0 , *)) {
117
+ resolve (@([RNExternalAppDelegateUtil isMainSceneActive ]));
118
+ } else {
119
+ reject (@" error" , @" Required iOS 13.0 or above" , nil );
120
+ }
108
121
});
109
122
}
110
123
@@ -114,13 +127,17 @@ - (NSDictionary *)constantsToExport
114
127
reject (@" error" , @" Not supported multiple scenes" , nil );
115
128
return ;
116
129
}
117
- [UIApplication.sharedApplication
118
- requestSceneSessionActivation: nil
119
- userActivity: nil // No activity as main scene
120
- options: nil
121
- errorHandler: nil // NOTE: No completion handler here so it is hard to use promise
122
- ];
123
- resolve (@YES );
130
+ if (@available (iOS 13.0 , tvOS 13.0 , *)) {
131
+ [UIApplication.sharedApplication
132
+ requestSceneSessionActivation: nil
133
+ userActivity: nil // No activity as main scene
134
+ options: nil
135
+ errorHandler: nil // NOTE: No completion handler here so it is hard to use promise
136
+ ];
137
+ resolve (@YES );
138
+ } else {
139
+ reject (@" error" , @" Required iOS 13.0 or above" , nil );
140
+ }
124
141
});
125
142
}
126
143
@@ -132,8 +149,7 @@ -(NSArray *)supportedEvents {
132
149
];
133
150
}
134
151
135
- // iOS 13+ only
136
- -(NSDictionary *)getUISceneInfo {
152
+ -(NSDictionary *)getUISceneInfo API_AVAILABLE(ios(13.0 )) {
137
153
NSSet *scenes = [UIApplication sharedApplication ].connectedScenes ;
138
154
NSMutableDictionary *screenInfo = [[NSMutableDictionary alloc ] init ];
139
155
for (UIWindowScene* scene in scenes) {
0 commit comments