Creating a public API method
The sample module code that Titanium creates as part of its module creation process provides us with a sample of a public method. We are going to create our own method, however. It will accept a single string input value (the long URL) and then process the short URL via the Bit.ly
API before returning it to our Titanium app.
Getting ready…
Before you can use the module, you'll need to sign up for a Bit.ly
API key, which you can do for free at https://bitly.com/a/your_api_key.
How to do it…
Open up ComPacktpubBitlyModuleModule.h
and ensure that it looks like the following (ignoring the header comments at the top of the file):
#import "TiModule.h" @interface ComPacktpubBitlyModuleModule : TiModule { } @end
Now, open the ComPacktpubBitlyModuleModule.m
file and ensure that it looks like the following source code (ignoring the header comments at the top of the file):
/** * BitlyModule * * Created by Jason Kneen * Copyright (c) 2015 Your Company. All rights reserved...