apptentive / apptentive-ios

Apptentive Legacy SDK for iOS. See https://github.com/apptentive/apptentive-kit-ios for Version 6.
http://www.apptentive.com/
BSD 3-Clause "New" or "Revised" License
146 stars 103 forks source link

Keyboard appearing over alert on iOS 8.3+ #150

Closed kristinkarpack closed 9 years ago

kristinkarpack commented 9 years ago

Tapping Yes from the "Do you love XYZ" prompt shows an alert and - on devices with iOS 8.3 and later - pops the keyboard, obscuring some of the buttons, especially on shorter devices. StackOverflow reconnaissance indicates this may be an issue with the deprecated UIAlertView - may need to upgrade this alert to UIAlertController to fi this issue on new OSes

pkamb commented 9 years ago

Hi, thanks very much for reporting this.

Is this happening on any particular device? Or all devices? Simulator?

Do you have a link to the Stack Overflow question you are referencing?

Thanks!

kristinkarpack commented 9 years ago

Thanks for following up! Here's the question I thought might be related: http://stackoverflow.com/questions/30129278/keyboard-pops-up-after-uialertview-is-dismissed-on-ios-8-3-for-ipad. We're seeing the behavior on iPhones/iPods and iPhone simulators on iOS 8.3 and 8.4. It doesn't happen 100% of the time but only happens on those OSes when it does.

Thanks, Kristin

valheru7 commented 9 years ago

Yes, we are having this issue too. The only workaround is for the user to close the app and open it agian and then the keyboard drops. (Obviously not the greatest workaround since the last thing you want is your user to close your app) (esp when they just said they liked the app)

pkamb commented 9 years ago

@kristinkarpack @valheru7 Thanks again for reporting this. I've investigated the issue and seem to have found the cause of this behavior.

In iOS 8.3+, it seems that when UIAlerts are "chained", odd-number alerts dismiss the keyboard. Even-number alerts bring it up again, and the keyboard then covers that alert.

This is a problem for Apptentive as our "Do you Love" alert transitions directly into the "Rate / Remind / No Thanks" alert.

You can see this with the code below. Try running showAlert when the keyboard is up. The first alert will dismiss the keyboard. After tapping a button, the delegate will show the alert again. This time (alert 2), the alert will bring up the keyboard and cover the alert. Tapping another button spawns an odd-number alert (3) and dismisses the keyboard. Alert 4 brings the keyboard up again. Etc.

- (void)showAlert {
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"UIAlertView" message:@"UIAlertView" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"1", @"2", @"3", nil];
    [alert show];
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
    [self showAlert];
}

This keyboard dismiss/show behavior only occurs when the initial UIAlert is presented while an existing keyboard is up. The UIAlertViews aren't causing a keyboard to pop up if none was there before.

As a short term solution, you can turn off Apptentive Ratings Prompt targeting at events that may be shown while the keyboard is up. This will prevent the issue from occurring in your app.

// Stop targeting Apptentive Ratings Prompt to `did_start_editing_text` event
// Via the Apptentive dashboard (no need for an App Store update)

[[ATConnect sharedConnection] engage:@"did_start_editing_text" fromViewController:self];

We will also be releasing a UIAlertController version of the SDK for iOS 8. I'll post here when that is released.

Let me know if you have any questions! Does your app have a specific "event while keyboard is up" event that is likely causing this issue?

pkamb commented 9 years ago

I've also reported this iOS UIAlertView bug as rdar://21838378

pkamb commented 9 years ago

I've added UIAlertController support to the Ratings Prompt on the RatingPromptUIAlertControllers branch, which should fix this issue in your app.

https://github.com/apptentive/apptentive-ios-private/tree/RatingPromptUIAlertControllers

Please let me know if you continue to experience any issues! I will be working on an official release for this as well.

sharjeelnisar1 commented 9 years ago

Hi, @pkamb!

I'm experiencing the same keyboard pop up issue on Ratigns Prompt. the link you provided in your last post, for a fix to this issue, isn't working. Can you please provide a valid link and help us to fix this issue. We'r experiencing decrease in downloads of our app, due to this issue.

I'll appreciate your quick response.

pkamb commented 9 years ago

Hi @sharjeelnisar1, has the patch in the branch above been applied correctly to your submodule? My guess is that you are still using the UIAlert version of the project. If the UIAlertController code is definitely being used, please let me know what behavior you see. Screenshots would be very helpful.

pkamb commented 9 years ago

In other news, my Radar for this issue has been acted upon. In iOS 9 beta 5, this odd/even keyboard pop-up behavior still occurs. However, it does not obscure the UIAlertView. The alert view is moved above the keyboard, and the title/message/buttons now scroll. Nothing is covered. So this is better behavior in iOS 9, at least.

pkamb commented 9 years ago

This should now be fixed thanks to UIAlertControllers in version 2.0.0:
https://github.com/apptentive/apptentive-ios/releases/tag/v2.0.0

ssglobal2015 commented 9 years ago

Hi pkamb, I have integrated latest version of Apptentive API (V2.0.2) iOS SDK into my application. Every thing working fine. Except the alerts are displayed at the top-left of my view controller. I ams struggling from a while to resolve this issue. Please provide solution to get workaround to resolve this issue.

![Uploading image005.png…]()

pkamb commented 9 years ago

Hi @ssglobal2015, can you please re-upload the screenshot?

Your issue is likely related to the question below, presenting a view from a UIAlertController.

http://stackoverflow.com/questions/27028983/uialertcontroller-is-moved-to-buggy-position-at-top-of-screen-when-it-calls-pre

Is it possible that you are passing a UIAlertController as the viewController parameter of engage:fromViewController:?