Skip to content

Conversation

kenwheeler
Copy link
Contributor

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 to inactive 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

appstate

@facebook-github-bot
Copy link
Contributor

By analyzing the blame information on this pull request, we identified @vjeux, @nicklockwood and @zjj010104 to be potential reviewers.

@facebook-github-bot facebook-github-bot added GH Review: review-needed CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. labels Mar 9, 2016
@kenwheeler
Copy link
Contributor Author

Fixes #524

NSString *newState = RCTCurrentAppBackgroundState();
NSString *newState;

if (notification.name == UIApplicationWillResignActiveNotification) {
Copy link
Contributor

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]) {

Copy link
Contributor Author

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 :)

@facebook-github-bot
Copy link
Contributor

@kenwheeler updated the pull request.

@kenwheeler
Copy link
Contributor Author

@nicklockwood Do I need to manually squash? Vaguely remember this being built in last time.

@grabbou
Copy link
Contributor

grabbou commented Mar 10, 2016

@kenwheeler facebook bot will squash all for you ;)

@kenwheeler
Copy link
Contributor Author

@grabbou thanks!

@kenwheeler kenwheeler changed the title Updating AppState to support the inactive state. [iOS] Updating AppState to support the inactive state. Mar 10, 2016
@nicklockwood
Copy link
Contributor

@facebook-github-bot shipit

@facebook-github-bot
Copy link
Contributor

Thanks for importing. If you are an FB employee go to Phabricator to review.

@ghost ghost closed this in ec9efb8 Mar 10, 2016
@ghost
Copy link

ghost commented Mar 14, 2016

\o/

ghost pushed a commit that referenced this pull request Mar 22, 2016
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
@facebook-github-bot
Copy link
Contributor

@kenwheeler updated the pull request.

1 similar comment
@facebook-github-bot
Copy link
Contributor

@kenwheeler updated the pull request.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants