Category: App Development

Capturing Text from Dictation in iOS

Capturing Text from Dictation in iOS

Users of your app can tap that little microphone key on the left side of the keyboard to speak what they would normally type in. A handy feature for users, but difficult to track in your application. While the UITextView or UITextField text property gets populated, it doesn’t call the standard delegates such as shouldChangeCharactersInRange.

How to capture the text from a UITextField:

Add this to your awakeFromNib or viewDidload method

[self.textField addTarget: self
action: @selector(eventEditingChanged:)
forControlEvents: UIControlEventEditingChanged];

The implementation of the eventEditingChanged method

-(void)eventEditingChanged:(UITextField *)sender {

if (sender.text.length <= 0) {
return;
}

UITextInputMode *inputMode = sender.textInputMode;
NSString *modeIdentifier = [inputMode respondsToSelector:@selector(identifier)] ? (NSString *)[inputMode performSelector:@selector(identifier)] : nil;

if([modeIdentifier isEqualToString:@"dictation"])
{
//do something with sender.text
}
}

How to capture the text from a UITextView:

Add this to your awakeFromNib or viewDidLoad method

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

The implementation of the modeChange method

-(void)modeChange:(NSNotification *)notification
{
NSString *inputMethod = self.textView.textInputMode.primaryLanguage;

if (inputMethod != nil) {
if (![inputMethod isEqualToString:@"dictation"]) {
//do something with self.textView.text
}
}
}

And finally remove the observer

- (void) dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}

Now your users will not be stifled from their laziness of not typing. Enjoy capturing that dictated text.

Implementing Base 36 in your iOS App

Implementing Base 36 in your iOS App

Base 36 can be a great way to represent a number with up to 8 alpha numeric characters. If you have an auto number and don’t want to represent it with just a number, you can convert it Base 36 to make it look a little sexier. Wikipedia has a great overview of the technology Base 36.

To convert a number to Base 36 you can use this c based algorithm

static char *base36enc(long unsigned int value)
{
	char base36[37] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	/* log(2**64) / log(36) = 12.38 => max 13 char + '\0' */
	char buffer[14];
	unsigned int offset = sizeof(buffer);
 
	buffer[--offset] = '\0';
	do {
		buffer[--offset] = base36[value % 36];
	} while (value /= 36);
 
	return strdup(&buffer[offset]);
}

Calling this from Objective-C and get the string value

char *wo = base36enc(someint)
NSString *stringValue = [NSString stringWithUTF8String:wo];

There you go. Pretty simple to use in your Objective-C app.

Side Bet Version 1.5 for iOS Released

Side Bet Version 1.5 for iOS Released

The latest update in the App Store includes the following updates:

  • Support for up to 5 players
  • Rounds can now have unlimited photos tied to them

The next version of Side Bet is in the works which will allow for photo sharing through Apple’s CloudKit framework.

I hope you enjoy the new version!

You can find Side Bet on the App Store here: Side Bet

iOS 8 API. A look at Home Kit

iOS 8 API. A look at Home Kit

developer_capabilities_icon_homekit

Home Kit is another exciting new framework being release with iOS 8 in the Fall of 2014. If you’d like to read the overview from Apple, they’ve posted an article explaining the high level features. Home Kit is similar to Health Kit in that the data is stored in a central database for other apps to interact with. I’ll be getting into some of the specifics of the API and an overview of the new Home Kit Accessory Simulator.

The main idea of Home Kit is to communicate with physical devices through an iOS device (iPod, iPhone, iPad). Siri is integrated into Home Kit so you can control physical devices through voice commands. It will be interesting to see all of the devices that will be integrated with Home Kit in the coming years. This will be a huge selling point for Apple going forward as more and more manufacturers come on board.

Here’s how the object hierarchy works: Home (HMHome) -> Rooms (HMRoom) -> Accessories (HMAccessory) -> Services (HMService). Rooms can also be grouped into zones (HMZone).

  • Home:
    A home is meant to be a single physical location. A user may have multiple homes set up on their device.
  • Rooms:
    A room is meant to be used as a grouping for a devices (accessories). An example is if you wanted all of your lights in your family room to be turned on or off at once, you could tell Siri “Turn on the lights in the family room”.
  • Accessories:
    Accessories are part of a home, but can also be assigned to a room in that home. An accessory is a physical device that is specially built to communicate with the Home Kit API. Your oven may be built to interact with the Home Kit API, so you could say “Preheat the oven to 350” (Which would be wicked cool).
  • Services:
    Services are different functions of an accessory. So an oven would have multiple features like heating, setting a timer, and turning the oven light on/off.
  • Zones:
    Rooms can be grouped into zones, so you could group all of your rooms in the basement into the basement zone. At that point you can command a function for all accessories in a collection of rooms such as “Turn off the lights in the basement”.

Let’s take a look at the Home Kit Accessory Simulator. In Beta 1 of XCode 6 you can add accessories for the HMAccessoryBrowser to find. I assume updates in the future will also allow developers to add services to interact with as well.

let browser = HMAccessoryBrowser()
browser.startSearchingForNewAccessories()

Screenshot 2014-06-16 13.54.04

Once your code identifies accessories in the home, you can then choose to add them to a room.

When Beta 2 is released I’ll expand on this article and show some concrete code examples.

After reviewing the Home Kit API, this could potentially be a really big deal for Apple. This will help take home automation to the next level making it mainstream in the next 3-5 years.

iOS 8 API. A look at Health Kit

iOS 8 API. A look at Health Kit

Health Kit is introduced with iOS 8 as part of the new HealthKit.framework. I created a new project to play around with the new functionality available to developers. The most interesting class to developers will be the HKHealthStore class which will allow the sharing of the user’s health data to other apps. The user chooses which data will be accessible to other applications.

The first thing you check for is the bool property isHealthDataAvailable. That will check if Health Kit is available on the device.

let dataAvailable = HKHealthStore.isHealthDataAvailable()

Health Kit allows the developer to write data to the Health Kit data store. Any data written by the app can be accessed for read and write access whenever it’s needed.

Before an app can access data, it must request access. 3 different types of access include BiologicalSex, BloodType and DateOfBirth:

HKCharacteristicTypeIdentifierBiologicalSex
HKCharacteristicTypeIdentifierBloodType
HKCharacteristicTypeIdentifierDateOfBirth

This is a simple introduction to the API as it has much more functionality for developers including the ability to write queries against the data.

Health Kit is sure to be a hit with iOS users as health related apps are already very popular in the app store. Being able to centralize a users data will add a lot of cohesiveness among apps which will bring a better user experience to iOS users going forward.

Apple advances tools and security to help keep their dominant position in the enterprise and education markets.

Apple advances tools and security to help keep their dominant position in the enterprise and education markets.

With Blackberry bleeding cash and recently laying off over 4,000 employees, they no longer have the privilege or owning the enterprise market. Blackberry’s share is so small in the enterprise now, they don’t even show up on most new activations charts. Blackberry’s CEO, John Chen, has given the company a 50/50 chance of survival. Enterprise needs a stable and dependable mobile technology partner. While Blackberry originally owned this market, Apple has made huge inroads in the last few years. In Q4 of 2013 mobile device activations favored Apple with a 73% market share for iPhones and over 91% for tablets with the iPad and iPad Mini. Tim Cook, CEO of Apple, has publicly stated how important the enterprise market is and how the company will continue to invest heavily in this space.

In February of 2014, Apple announced welcome changes to enterprise deployment, management and security. Apple also made it easier on students by allowing them to sign up for their own Apple IDs if the student is under the age of 13. The under 13 IDs require parental support to sign up and Apple also sets limitations on what services are available.

Apple has updated their Enterprise Deployment Overview document which explains how devices can deployed along with integrating personal devices as hybrid approach. Being able to support BYOD (bring your own device) is very important for enterprise deployment, seeing as how many employees are already carrying a mobile device with them. In a BYOD environment users can enroll in their corporate mobile device management (MDM) program by initiating the installation of a configuration profile on their device. If the owner of the device leaves the company, they can simply remove the profile. The devices can then be provisioned for apps and remotely managed just like a company purchased MDM device.

With employees reluctant to carry a Windows Phone, and Android still being having the perception of not being a secure platform, Apple should continue to dominate the enterprise market. They are definitely making it easy on corporations allowing volume discounts, purchase orders and devices configured before they are shipped. Apple’s focus on security only strengthens the argument to deploy/manage iOS devices for its employees.

This post was originally written for the Aspenware blog

Keystone Laboratories iOS App Released

Keystone Laboratories iOS App Released

Keystone Laboratories, Inc. has just released it’s first mobile app in the iTunes store. The app is free and is currently available for download on iPhones running iOS 7.0 and higher. Customers will be able to view their sample results through the Keystone Laboratories app once they have a username and password set up with their project manager. Josh King, the developer of the application, states that “This is just the beginning for getting your sample data to your mobile device. I’d love to hear feedback on the current version and what you’d like to see in the future. I have a first draft of an iPad application as well.”

Jeff King, Laboratory Directory, exclaims “This app will go along way with adding value to the customer experience. Josh has done a great job developing the app in a short amount of time.”

To check out the app for yourself, view it in the iTunes store. Keystone Laboratories – Josh King

Installing the Nokia Imaging SDK

Installing the Nokia Imaging SDK

Working with the Nokia Imaging SDK isn’t as easy as just installing the NuGet package. There are 2 dlls that will likely not be reference properly.

  • Nokia.Graphics.Imaging
  • Nokia.InteropServices.Runtime

If you try and add them manually you may get an error message like this: A reference to a higher version or incompatible…

Nokia has a post on how to solve this problem. The key is to remove Any CPU from your build configuration, and then close and re-open the solution.

http://developer.nokia.com/Resources/Library/Lumia/#!nokia-imaging-sdk/adding-libraries-to-the-project.html

Side Note Version 1.3 Released!

Side Note Version 1.3 Released!

Side Note has been updated to be a much more friendly and appealing user interface. With this new update users can add a little color to their notes, which makes the experience of saving and viewing your notes a little more fun. With 165 downloads over the last 5 days, there is a demand for this kind of capability on phones. People want to keep track of random notes, and they want a simple and efficient way to do so. If you have a Windows 8 Phone, try it out. It’s free!

Side Note
Side Note
Go Native or go HTML5?

Go Native or go HTML5?

HTML5_Logo

I’ve got a new idea for an App, and I’m really good at Windows Phone development, so my first instinct is so start writing the app specifically for that platform. I’m currently trying to decide if that’s a good idea or not. Ideally I’d want my app to work across all 3 major platforms (iPhone, Android & Windows Phone).

To develop specifically for each platform would take a significant amount of time. Each platform uses a different programming language.

  • iOS: Objective-C
  • Android: Java
  • Windows Phone: Silverlight/C#

Being a C# guy, Xamarin looks like a good choice for my app. I’m somewhat dreading developing the app with html and javascript. Not that I don’t know how to develop with that technology, it’s just a little more painful than writing C# and XAML. Once you’ve experienced data-binding with XAML, it’s such a wonderful experience you never want to develop any other way.

As I write this post, I’m still not sure what way I will go. I think I’ll give Xamarin a shot and if that proves to be too painful I’ll probably go the HTML5 route. There’s no way I’m writing a native app for each platform. Maybe I would if I didn’t have a full time job bu the time constraints are too high.

I look forward to your comments on the topic!