expo-splash-screen 0.13.2 → 0.13.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -10,6 +10,12 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 0.13.3 — 2021-10-15
14
+
15
+ ### 🐛 Bug fixes
16
+
17
+ - Fix `No native splash screen registered for given view controller` error happening when project is using both `expo-dev-client` and `expo-splash-screen` packages. ([#14745](https://github.com/expo/expo/pull/14745) by [@kudo](https://github.com/kudo))
18
+
13
19
  ## 0.13.2 — 2021-10-15
14
20
 
15
21
  _This version does not introduce any user-facing changes._
@@ -3,7 +3,7 @@ apply plugin: 'kotlin-android'
3
3
  apply plugin: 'maven'
4
4
 
5
5
  group = 'host.exp.exponent'
6
- version = '0.13.2'
6
+ version = '0.13.3'
7
7
 
8
8
  buildscript {
9
9
  // Simple helper that allows the root project to override versions declared by this library.
@@ -57,7 +57,7 @@ android {
57
57
  minSdkVersion safeExtGet('minSdkVersion', 21)
58
58
  targetSdkVersion safeExtGet('targetSdkVersion', 30)
59
59
  versionCode 17
60
- versionName '0.13.2'
60
+ versionName '0.13.3'
61
61
  }
62
62
  lintOptions {
63
63
  abortOnError false
@@ -4,12 +4,22 @@
4
4
  #import <EXSplashScreen/EXSplashScreenViewNativeProvider.h>
5
5
  #import <ExpoModulesCore/EXDefines.h>
6
6
 
7
- static const NSString *kView = @"view";
7
+ static NSString * const kRootViewController = @"rootViewController";
8
+ static NSString * const kView = @"view";
8
9
 
9
10
  @interface EXSplashScreenService ()
10
11
 
11
12
  @property (nonatomic, strong) NSMapTable<UIViewController *, EXSplashScreenViewController *> *splashScreenControllers;
12
- @property (nonatomic, assign) BOOL isObservingRootViewController;
13
+ /**
14
+ * This module holds a reference to rootViewController acting as a flag to indicate KVO is enabled.
15
+ * When KVO is enabled, actually we are observing two targets and re-show splash screen if targets changed:
16
+ * - `keyWindow.rootViewController`: it is for expo-dev-client which replaced it in startup.
17
+ * - `rootViewController.rootView`: it is for expo-updates which replaced it in startup.
18
+ *
19
+ * If `rootViewController` is changed, we also need the old `rootViewController` to unregister rootView KVO.
20
+ * That's why we keep a weak reference here but not a boolean flag.
21
+ */
22
+ @property (nonatomic, weak) UIViewController *observingRootViewController;
13
23
 
14
24
  @end
15
25
 
@@ -21,7 +31,6 @@ EX_REGISTER_SINGLETON_MODULE(SplashScreen);
21
31
  {
22
32
  if (self = [super init]) {
23
33
  _splashScreenControllers = [NSMapTable weakToStrongObjectsMapTable];
24
- _isObservingRootViewController = NO;
25
34
  }
26
35
  return self;
27
36
  }
@@ -141,23 +150,39 @@ EX_REGISTER_SINGLETON_MODULE(SplashScreen);
141
150
  - (void)addRootViewControllerListener
142
151
  {
143
152
  NSAssert([NSThread isMainThread], @"Method must be called on main thread");
144
- if (!_isObservingRootViewController) {
145
- [UIApplication.sharedApplication.keyWindow.rootViewController addObserver:self forKeyPath:kView options:NSKeyValueObservingOptionNew context:nil];
146
- _isObservingRootViewController = YES;
153
+ if (self.observingRootViewController == nil) {
154
+ UIViewController *rootViewController = UIApplication.sharedApplication.keyWindow.rootViewController;
155
+
156
+ [UIApplication.sharedApplication.keyWindow addObserver:self
157
+ forKeyPath:kRootViewController
158
+ options:NSKeyValueObservingOptionNew
159
+ context:nil];
160
+
161
+ [rootViewController addObserver:self forKeyPath:kView options:NSKeyValueObservingOptionNew context:nil];
162
+ self.observingRootViewController = rootViewController;
147
163
  }
148
164
  }
149
165
 
150
166
  - (void)removeRootViewControllerListener
151
167
  {
152
168
  NSAssert([NSThread isMainThread], @"Method must be called on main thread");
153
- if (_isObservingRootViewController) {
154
- [UIApplication.sharedApplication.keyWindow.rootViewController removeObserver:self forKeyPath:kView context:nil];
155
- _isObservingRootViewController = NO;
169
+ if (self.observingRootViewController != nil) {
170
+ [UIApplication.sharedApplication.keyWindow removeObserver:self forKeyPath:kRootViewController context:nil];
171
+ [self.observingRootViewController removeObserver:self forKeyPath:kView context:nil];
172
+ self.observingRootViewController = nil;
156
173
  }
157
174
  }
158
175
 
159
176
  - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context
160
177
  {
178
+ if (object == UIApplication.sharedApplication.keyWindow && [keyPath isEqualToString:kRootViewController]) {
179
+ UIViewController *newRootViewController = change[@"new"];
180
+ if (newRootViewController != nil) {
181
+ [self removeRootViewControllerListener];
182
+ [self showSplashScreenFor:newRootViewController];
183
+ [self addRootViewControllerListener];
184
+ }
185
+ }
161
186
  if (object == UIApplication.sharedApplication.keyWindow.rootViewController && [keyPath isEqualToString:kView]) {
162
187
  UIView *newView = change[@"new"];
163
188
  if (newView != nil && [newView.nextResponder isKindOfClass:[UIViewController class]]) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-splash-screen",
3
- "version": "0.13.2",
3
+ "version": "0.13.3",
4
4
  "description": "Provides a module to allow keeping the native Splash Screen visible until you choose to hide it.",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -39,10 +39,10 @@
39
39
  "dependencies": {
40
40
  "@expo/configure-splash-screen": "^0.6.0",
41
41
  "@expo/prebuild-config": "^3.0.0",
42
- "expo-modules-core": "~0.4.3"
42
+ "expo-modules-core": "~0.4.4"
43
43
  },
44
44
  "devDependencies": {
45
45
  "expo-module-scripts": "^2.0.0"
46
46
  },
47
- "gitHead": "d23e1ac491da96b51c25eb2533efcd56499ee287"
47
+ "gitHead": "e30402e90972d9e1838d7b63a40a71a41398a772"
48
48
  }