Use native initialAppState to init app_state for AppStateIOS.

This commit is contained in:
Alexey Lang 2015-08-25 09:08:44 -07:00
parent 245a5b8e8c
commit 2d2252cd50
2 changed files with 10 additions and 5 deletions

View File

@ -122,11 +122,7 @@ var AppStateIOS = {
_eventHandlers[type].delete(handler);
},
// TODO: getCurrentAppState callback seems to be called at a really late stage
// after app launch. Trying to get currentState when mounting App component
// will likely to have the initial value here.
// Initialize to 'active' instead of null.
currentState: ('active' : ?string),
currentState: (RCTAppState && RCTAppState.initialAppState : ?string),
};

View File

@ -96,4 +96,13 @@ RCT_EXPORT_METHOD(getCurrentAppState:(RCTResponseSenderBlock)callback
callback(@[@{@"app_state": _lastKnownState}]);
}
#pragma mark - RCTBridgeModule
- (NSDictionary *)constantsToExport
{
return @{
@"initialAppState" : RCTCurrentAppBackgroundState()
};
}
@end