Disable Dictation button on the keyboard of iPhone 4S / new iPad

Ours is a health care app. We have a HIPAA-compliant speech recognizer in the app through which all the dictation can take place. The hospitals don’t want physicians to accidentally start speaking to the Nuance Dragon server which is not HIPAA-compliant. So, I was looking for ways I could supress the dictation key on the keyboard.

I tried putting a fake button on the Dictation button on the key pad, but on the iPad the split dock concept keeps moving the microphone all over the screen. This does not sound like a reasonable solution. Are there any experts out there who could help me?

  • iOS - How to check if a modal view is present
  • UITextView starting from bottom
  • how can i connect to a password proctected wifi named as “A”
  • Changing the UINavigationBar background image
  • Can't find headers for GoogleAnalytics-iOS-SDK with Cocoapods 0.37, Swift, frameworks
  • Distinguish between iPhone 4 and iPhone 4S
  • 4 Solutions Collect From Internet About “Disable Dictation button on the keyboard of iPhone 4S / new iPad”

    OKAY, finally got it! The trick is to observe UITextInputMode change notifications, and then to gather the identifier of the changed mode (Code seems to avoid the direct use of Private API, though seems to require a little knowledge of private API in general), and when the mode changes to dictation, resignFirstResponder (which will cancel the voice dictation). YAY! Here is some code:

    Somewhere in your app delegate (at least that’s where I put it)

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(inputModeDidChange:) name:@"UITextInputCurrentInputModeDidChangeNotification"
                                               object:nil];
    

    And then you can

    UIView *resignFirstResponder(UIView *theView)
    {
        if([theView isFirstResponder])
        {
            [theView resignFirstResponder];
            return theView;
        }
        for(UIView *subview in theView.subviews)
        {
            UIView *result = resignFirstResponder(subview);
            if(result) return result;
        }
        return nil;
    }
    
    - (void)inputModeDidChange:(NSNotification *)notification
    {        
        // Allows us to block dictation
        UITextInputMode *inputMode = [UITextInputMode currentInputMode];
        NSString *modeIdentifier = [inputMode respondsToSelector:@selector(identifier)] ? (NSString *)[inputMode performSelector:@selector(identifier)] : nil;
    
        if([modeIdentifier isEqualToString:@"dictation"])
        {
            [UIView setAnimationsEnabled:NO];
            UIView *resigned = resignFirstResponder(window);
            [resigned becomeFirstResponder];
            [UIView setAnimationsEnabled:YES];
    
            UIAlertView *denyAlert = [[[UIAlertView alloc] initWithTitle:@"Denied" message:nil delegate:nil cancelButtonTitle:@"Okay" otherButtonTitles:nil] autorelease];
            [denyAlert show];
        }
    }
    

    you can create your own keyboard and set the inputView for the text fields that will accept this dictation. then when they press any keys they will get your keyboard, therefore you dont have to override the keys on the standard keyboard, you will be able to customize the entire thing.

    self.myButton.inputView = self.customKeyboardView;
    

    here is an example of an extremely custom keyboard

    http://blog.carbonfive.com/2012/03/12/customizing-the-ios-keyboard/

    Ray also has a teriffic tutorial on custom keyboards.

    http://www.raywenderlich.com/1063/ipad-for-iphone-developers-101-custom-input-view-tutorial

    I hope that helps.

    I had the same issue and the only way i found that hides the dictation button is changing the keyboard type.
    For me changing it to email type seemed to be reasonable:

    textField.keyboardType = UIKeyboardTypeEmailAddress;
    

    You could make a subclass of UITextField/UITextView that overrides insertDictationResult: to not insert anything.

    This won’t prevent the information being sent, but you could then display an alert informing them of the breech.