Clone wiki

GVoice / Home


This is an iOS library in Objective-C for interacting with Google Voice. I borrowed liberally from google-voice-java which, as its name implies, was written in Java. This is not a direct port of google-voice-java, however. I made changes that made sense for Objective-C, and took several of the methods farther than they had been, returning NSDictionary objects with useful contents, instead of just raw strings.

It also makes use of json-framework for dealing with the JSON responses from Google Voice.

Note: This library is not affiliated with Google in any way.


Clone the repository, or download a snapshot and unzip it somewhere. Copy/rename the file called GVTests/GVCredentials-Sample.h to GVTests/GVCredentials.h before trying to build. In Xcode 4, there seem to be several ways to link against a static library, all of which are not very Mac-like, and have their own quirks. Pick the one that you like best/hate least.

The current settings are working for me right now with a workspace containing my iPhone app and this library. YMMV.


You need to create a GVoice object in your code, save it somewhere (e.g. a property), and then send it messages. This code is not thread safe, so if you are working in a multi-threaded project, you need to do your own synchronization. Here's a basic example:

// USERNAME, PASSWORD, SOURCE and ACCOUNT_TYPE should be replaced with proper
// values. 
self.voice = [[GVoice alloc] initWithUser: USERNAME password: PASSWORD source: SOURCE 
								  accountType: ACCOUNT_TYPE];

// This causes some logging to happen.
self.voice.logToConsole = YES;

BOOL res = [self.voice login];

if (!res) {
    // error handling

// Assuming you have a phone whose id is 23, this would cause Google Voice
// to route calls to it.
res = [self.voice enablePhone: 23]

if (!res) {
    // error handling

// Send an SMS. Replace TEXT_PHONE_NUMBER with a proper 10-digit phone number
// capable of receiving SMS messages
res = [self.voice sendSmsText: @"Testing 1, 2, 3" toNumber: TEXT_PHONE_NUMBER];

if (!res) {
    // error handling

Error Handling

You can check the errorCode property of the GVoice object, which returns an enum of type GVoiceErrorCode. If the value is NoError, then things should be OK. There is also a property called errorDescription that has an English description of the error. If the errorCode is Unknown, then you can check the rawErrorText property to see if it contains anything useful.

Test Suite

There is a set of tests that can easily be run from Xcode 4. In order to run these tests, or even to compile them, you need to copy/rename the file called GVCredentials-Sample.h to GVCredentials.h, and then edit it to put valid values for each of the #defines there.

API Docs

Full API docs are available in the distribution under the doc/ directory. If someone can tell me how to link to them here, I will do so.

Still To Do

  • Handle CAPTCHA requests
  • Handle redirects

Apps Using GVoice

List of Apps Using GVoice