-
Notifications
You must be signed in to change notification settings - Fork 24.8k
[iOS] Updating AppState to support the inactive state. #6379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
By analyzing the blame information on this pull request, we identified @vjeux, @nicklockwood and @zjj010104 to be potential reviewers. |
Fixes #524 |
NSString *newState = RCTCurrentAppBackgroundState(); | ||
NSString *newState; | ||
|
||
if (notification.name == UIApplicationWillResignActiveNotification) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's unsafe to use == for string comparisons in Objective-C. It probably happens to work in this case because they are constants, and so the pointer is the same, but it's best practice to write this as:
if ([notification.name isEqualToString:UIApplicationWillResignActiveNotification]) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nicklockwood Updated. Sorry about that, my javascript is showing :)
@kenwheeler updated the pull request. |
@nicklockwood Do I need to manually squash? Vaguely remember this being built in last time. |
@kenwheeler facebook bot will squash all for you ;) |
@grabbou thanks! |
@facebook-github-bot shipit |
Thanks for importing. If you are an FB employee go to Phabricator to review. |
\o/ |
Summary:Changing app state back to 'background' for UIApplicationWillEnterForegroundNotification. On iOS we use the 'background' app state to determine whether a notification was tapped to foreground the app vs. received while app was already active. The PR #6379 changed RCTAppState so that it returned 'active' when app was being foregrounded from a notification; this changes it back to 'background' so that we can distinguish between the two cases again Reviewed By: hedgerwang Differential Revision: D3078746 fb-gh-sync-id: 8b5e9118a7e14f15871bfb68e9f85d20108b1faf shipit-source-id: 8b5e9118a7e14f15871bfb68e9f85d20108b1faf
@kenwheeler updated the pull request. |
1 similar comment
@kenwheeler updated the pull request. |
Motivation
AppStateIOS never currently returns
inactive
as a possible state. I had a requirement that when inactive, certain portions of the app should be blacked out in accordance with compliance rules. This is not possible currently, due toinactive
never being returned. This PR fixes that.Test plan
All base tests are passing. Are there AppState specific tests in place at the moment that I'm missing?
Demonstration