Wednesday, December 17, 2014

3rd Party Keyoard in iOS - App developer perspective

Few notes on Third party keyboards in iOS. 

- The main reason with the UI Alignment issue was because of the keyboard height was coming as zero for with the methods we use. 

Initially when the keyboard shown notification arrives at the application, below method is used to get the keyboard height 
[[[aNotification userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey] getValue:&rectKeyboardFrame];

However, above gives height zero for  third party keyboards while it works well with the System keyboard. Since the view is moved up based on the height returned from this API, the ui looks distorted. To fix the issue, we can replace the API call to the below if in case the height comes as zero. 

[[[aNotification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] getValue:&rectKeyboardFrame];

Also, as per the documentation, there are some privacy concerns when user employs the third party keyboard. 

An app developer can elect to reject the use of all custom keyboards in their app. For example, the developer of a banking app, or the developer of an app that must conform to the HIPAA privacy rule in the US, might do this. Such an app employs the application:shouldAllowExtensionPointIdentifier: method from theUIApplicationDelegate protocol (returning a value of NO), and thereby always uses the system keyboard.

This is mainly because these keyboards iOS 8.0 extension can potentially communicate the keystrokes to the server if these are run with full access (in keyboard settings).  

If the app has any payment related features, we can give kind of warning to the user and if user don’t want to enable third party keyboard, then application can altogether reject the third party keyboard for the app. In terms of using the above method, below are few observations on this.

- This method called to the app, whenever user activates the keyboard by tapping on the text fields. However, this method called back for even System keyboard with the same extension point identifier value which gives difficulty for an app to show a warning message if only user has 3rd party keyboard. Not sure this is a bug and will be fixed later in Apple releases, but we observe this in multiple iOS 8.x version as of now. 


- This method if returned NO, altogether disables the 3rd party keyboard for the app. This works well, however, this is not flexible enough to disable the third party keyboard only for  certain screens. For e.g. Not possible to disable third party keyboard for only for payment screens. 

References: 

No comments:

Post a Comment