My swift iOS app has an active textfield with keyboard showing.
Everytime user taps the return key on keyboard, I call
SKStoreReviewController.requestReview()
This may sound excessive but once the user has given the review, above statement will not do anything so I think my approach is correct.
Problem is that on smaller screen devices (iPhone 5 etc), the displayed SKStoreReviewController's buttons are hidden under the keyboard.
So the user gets stuck as they cannot dismiss the SKStoreReviewController.
I do not want to add a keyboard hide button for the user.
How can I know when SKStoreReviewController
did display so I can programmatically hide the keyboard?
There is no way for you to tell if it is being displayed.
You can read the documentation on SKStoreReviewController
here, which shows only the requestReview() function you use to call it.
But, if you want to dig deeper, I provide the following screenshot which shows what the Debug View Hierarchy looks like while displaying the request.
What this tells you, is that there is nothing you can try to dig down to via properties such as presentedViewController
in an attempt to divine if the screen is being presented.
Normally, if you are presenting a UIAlertController
, or any UI element for that matter, you will see the UI pieces stacked together that form it, indicating that you can access associated properties to find out what is being presented. With this class, none of that is provided so your app is oblivious to what is going on.
The following screenshot illustrates what a view hierarchy looks like when you have multiple elements on the screen:
As Apple alludes to in the class documentation, you need to develop your own logic for presenting it at a time when it will not present the issue you are currently experiencing.
I just answered this question here:
Mechanism to detect display of iOS 10.3 app rating dialog?
You can setup your text field to dismiss the keyboard when the rating view is shown and enable the keyboard again when the rating view is dismissed:
- (void)windowDidBecomeVisibleNotification:(NSNotification *)notification
{
if([notification.object class] == [MonitorObject class])
{
NSLog(@"Review Window shown");
[self.enterCodeView resignFirstResponder];
}
}
- (void)windowDidBecomeHiddenNotification:(NSNotification *)notification
{
if([notification.object class] == [MonitorObject class])
{
NSLog(@"Review Window hidden!");
[self.enterCodeView becomeFirstResponder];
}
}