Professional Documents
Culture Documents
Proprietary Notice
Table of Contents
1 Introduction ................................................................................................... 5
1.1 Purpose.................................................................................................... 5
1.2 Audience .................................................................................................. 5
1.3 Prerequisites ............................................................................................. 5
2 SDK Contents.................................................................................................. 6
5 Advertisements ............................................................................................ 10
5.1 Initialization .............................................................................................10
5.2 Adopt the VeltiViewDelegate Protocol .........................................................10
5.3 Insert a VeltiView Object ...........................................................................11
5.3.1 Programmatically Add a Custom Sized VeltiView .............................................. 11
5.3.2 Programmatically Add an Interstitial VeltiView ................................................. 11
5.3.3 Add a VeltiView Using Interface Builder ........................................................... 12
6 Click-to-Action .............................................................................................. 13
6.1 Initialization .............................................................................................13
6.2 Custom Application URL ............................................................................13
6.3 CFBundleVersion ......................................................................................13
6.4 CFBundleIdentifier ....................................................................................14
7 Statistics ....................................................................................................... 15
7.1 Initialization .............................................................................................15
7.2 Event Logging ..........................................................................................15
7.2.1 Standard Event Tracking ............................................................................... 15
7.2.2 Event Duration Tracking ................................................................................ 16
7.2.3 Supplementary Event Properties .................................................................... 17
7.3 Application Session Tracking......................................................................17
7.4 Location Tracking .....................................................................................17
7.4.1 Managed Location ......................................................................................... 18
7.4.2 Application Provided Location ......................................................................... 18
7.5 CFBundleIdentifier ....................................................................................18
1 Introduction
1.1 Purpose
This document describes how to integrate and utilize the application programming
interface for displaying ads, tracking application statistics, and tracking click to
action within an iPhone application using the Velti iPhone SDK. The API uses
Objective C and the iPhone SDK.
1.2 Audience
This document is intended for iPhone application developers familiar with the
iPhone SDK and Xcode developer tools as well as the Objective C programming
language.
This document is intended to aid actual and prospective developers in scoping and
planning integration via the Velti iPhone SDK. It is not intended to enable
developers to execute integration without further information and support from
Velti. Please contact Velti to arrange for API integration support.
1.3 Prerequisites
Before integrating the Velti iPhone SDK, the partner needs to:
2 SDK Contents
Note that the debug static library is built with debug output enabled and is included to
help assist with debugging activities should that be required. However, it is strongly
advised to use the non-debug static library for your final application distribution as it
has been optimized for performance.
Note that the static libraries are multi-architectural binaries built using the lipo utility
and thus are capable of running on device architectures as well as through the
simulator.
The SDK integrates with your application using the Xcode IDE. The following
sections provide step by step instructions which detail the SDK installation process.
3. You will be prompted upon adding the SDK contents to your application with
the following window:
Note the Application targets identified by the icon under the Targets section in
your Xcode project.
QuartzCore.framework Required
MediaPlayer.framework Required
UIKit.framework Required
Foundation.framework Required
CoreGraphics.framework Required
MessageUI.framework Weak
SystemConfiguration.framework Required
CoreLocation.framework Required
libsqlite3.dylib Required
The following sections provide discussion and code snippets that demonstrate
application delegate integration that is required for all Velti iPhone SDK features.
@class SampleViewController;
- (void)veltiManagerErrorOccurred:(NSError *)error {
}
- (void)applicationDidFinishLaunching:(UIApplication *)application {
[[VeltiManager sharedInstance] setDelegate:self];
[[VeltiManager sharedInstance] initialize];
[window addSubview:viewController.view];
[window makeKeyAndVisible];
}
5 Advertisements
The following sections provide discussion and code snippets that demonstrate how
to make ad requests using Velti iPhone SDK within your application.
5.1 Initialization
The following example illustrates the steps provided above and includes the
required advertisement properties.
- (void)applicationDidFinishLaunching:(UIApplication *)application {
...
[[VeltiManager sharedInstance] setServerUrl:@"http://server-name"];
[[VeltiManager sharedInstance] initialize];
...
}
#import "VeltiView.h"
- (void)veltiViewAdAvailable:(VeltiView *)veltiView {
}
- (void)veltiViewNoAdAvailable:(VeltiView *)veltiView {
}
- (void)veltiViewAdFinished:(VeltiView *)veltiView {
}
A VeltiView instance represents the container that will display an ad and may be
added to the parent view programmatically or through Interface Builder.
The following sections detail various approaches for adding a VeltiView object into
your application.
- (void)viewDidLoad {
CGRect frame = CGRectMake(0.0, 0.0, 320.0, 64.0);
VeltiView *veltiView = [[VeltiView alloc] initWithFrame:frame];
[veltiView setDelegate:self];
[veltiView setName:@"unique name"];
[veltiView setPID:@"partner id"];
[veltiView setCID:@"content id"];
[veltiView requestNewAd];
[self.view addSubview:veltiView];
[veltiView release];
[super viewDidLoad];
}
[veltiView setDelegate:self];
[veltiView setName:@"unique name"];
[veltiView setPID:@"partner id"];
[veltiView setCID:@"content id"];
[veltiView requestNewAd];
[veltiView displayInterstital];
[veltiView release];
The VeltiViewDelegate protocol provides the following method for the controller
which displayed the interstitial VeltiView to be notified when the user closes the
interstitial ad.
- (void)veltiViewAdFinished:(VeltiView *)veltiView;
VeltiView instances may be created using Interface Builder. Note the following:
The File’s Owner must provide an IBOutlet VeltiView property.
Once the UIView instance is added which will be used to display the ad, the
VeltiView class must be specified from the Tools->Identity Inspector from
the Class drop down.
Provide the IBOutlet connection from the VeltiView instance to the File’s
Owner corresponding VeltiView property.
6 Click-to-Action
The following sections provide discussion and code snippets that demonstrate how
to use the click-to-action feature provided by Velti iPhone SDK within your
application.
6.1 Initialization
The following example illustrates the steps provided above and includes the
required click to action properties.
- (void)applicationDidFinishLaunching:(UIApplication *)application {
...
[[VeltiManager sharedInstance] setEnableClickToAction:TRUE];
[[VeltiManager sharedInstance] setCPAServerUrl:@"http://server-name"];
[[VeltiManager sharedInstance] setCustomApplicationUrl:@"sample://"];
[[VeltiManager sharedInstance] setCampaign:@"campaign"];
[[VeltiManager sharedInstance] initialize];
...
}
Click to action requires that your application register a custom URL scheme and
provide the value to the VeltiManager as the customApplicationUrl property.
Details on registering a custom URL scheme are provided in Apple’s documentation.
6.3 CFBundleVersion
The CFBundleVersion must be specified in the application’s plist file and is used to
identify the application version. This value is expected to conform to the following
standard defined by Apple:
6.4 CFBundleIdentifier
The CFBundleIdentifier must be specified in the application’s plist file and is used
to uniquely identify the application.
7 Statistics
The following sections provide discussion and code snippets that demonstrate how
to use the application statistics feature provided by Velti iPhone SDK within your
application.
7.1 Initialization
Note that statistics are always sent upon application start if they have not been sent
previously. Sending statistics upon application termination can increase the time it
takes for the application to exit depending upon network speeds, however, the
statistics are immediately available without the need for a subsequent application
launch. Also note that statistics are sent only when a network connection is
available, otherwise they saved and are sent upon subsequent application launch or
termination accordingly.
The following example illustrates the steps provided above and includes the
required statistics properties.
- (void)applicationDidFinishLaunching:(UIApplication *)application {
...
[[VeltiManager sharedInstance] setEnableStatistics:TRUE];
[[VeltiManager sharedInstance] setStatisticsServerUrl:@"http://server-name"];
[[VeltiManager sharedInstance] setPID:@"partner id"];
[[VeltiManager sharedInstance] setSendStatisticsOnApplicationTermination:TRUE];
[[VeltiManager sharedInstance] initialize];
...
}
Various forms of event tracking are available and may be logged at any point after
the VeltiManager is initialized.
Note that the Velti iPhone SDK automatically provides a timestamp for each event collected.
The following sections discuss the available forms of event logging in more detail.
This is the simplest form of tracking an event in which the name of the event is
provided by the application as shown in the following example.
When tracking the duration of an event, the start of the event must be provided
followed by the end of the event at some point later. Note that the start and end
event names must match identically and there may be no more than one event
duration measured at any time for a given unique event name. The following
example illustrates event duration tracking.
Additional event properties may be provided using one of the signatures that
accepts an NSDictionary instance. Note the following NSDictionary usage
requirements:
Keys must be NSString instances and must not exceed 255 characters.
Standard events as well as event duration tracking both provide a mechanism for
specifying supplementary event properties as shown in the following examples.
...
The Velti iPhone SDK automatically tracks each application launch and termination
as well as the duration of the resulting session when statistics are enabled.
Application statistics may include location information provided that the feature has
been enabled. However, Apple has a strict policy that could cause your application
to be rejected. Note the following:
Two approaches for providing location statistics are available and are discussed in
the following sections.
When this property is enabled, the Velti iPhone SDK will automatically manage the
location services and provide the corresponding data to all application events
collected. This property should be set in the application delegate class before the
VeltiManager is initialized.
- (void)applicationDidFinishLaunching:(UIApplication *)application {
...
[[VeltiManager sharedInstance] setEnableLocationTracking:TRUE];
[[VeltiManager sharedInstance] initialize];
...
}
Alternatively, if the application is already using core location services, then it may
provide a CLLocation instance whose data will be applied to all application events
collected from that point forward. This property may be set more than once,
however, only the most recent instance is used and any previously collected events
remained unchanged by the updated location data. This property may only be used
when enableLocationTracking is set to FALSE.
The following example illustrates how to provide a CLLocation instance which may
be done at any point while the application is running and is not required to be set
before the VeltiManager is initialized.
- (void)someMethod:(CLLocation *)location {
[[VeltiManager sharedInstance] setLocation:location];
}
7.5 CFBundleIdentifier
The CFBundleIdentifier must be specified in the application’s plist file and is used
to uniquely identify the application.
It is strongly recommended that this value be the same for each platform
where statistics are being tracked.
7.6 CFBundleShortVersionString
8 Additional Features
The following sections illustrate how to use additional features available in the SDK.
Note that uses of these features are optional.
Activity indicators are available which visually indicate the indeterminate progress
of an ad request and are centered horizontally and vertically within the space
allocated for a given VeltiView instance.
[veltiView setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleGray];
8.2 Animations
View transitions are available and provide a fade effect which occurs under the
following conditions when animations are enabled:
The following example illustrates how to enable animations and specify the duration
of the animation, in seconds, for a VeltiView instance. Note that the animation
properties must be specified before the ad request is invoked.
[veltiView setEnableAnimations:TRUE];
[veltiView setAnimationDuration:0.2l];
The local landing page feature displays click through URLs within the application
where support is available. This feature is disabled by default.
For http:// click through URLs that are not iTunes, App Store or video links, a
browser style interface with orientation change support is displayed with the
following controls:
Back
Forward
Stop
Reload
Close button to return to the application
Display content in Safari
For http:// click through URLs that represent video, the media player is displayed
with playback starting when a sufficient amount of data has been streamed to the
device. The following video formats are supported:
For mailto:// click through URLs, an email composition view is displayed and
populated with the contents specified in the click through URL. Note that the local
email composition view is displayed for devices running iPhone OS 3.0 or later.
Devices with OS versions older than version 3.0 display email click through URLs in
the Mail app, thus causing the application to exit.
Note that if the click through URL represents any of the following types, the
appropriate native application is displayed causing the application to exit:
iTunes
App Store
Map
Phone
SMS
The following example illustrates how to enable the local landing page feature and
customize the display to integrate with the application color scheme.
Enable local landing page mode in the application delegate class. This is a global
setting that applies to all VeltiView instances.
Configure the local landing page toolbar display for each VeltiView instance using
either the toolbar style or tint color methods. The following examples set the tool
bar style and tint color respectively.
[veltiView setToolbarStyle:UIBarStyleBlack];
[veltiView setTranslucentToolbar:FALSE];
Enabling the application exit confirmation feature displays a popup dialog for the
user to confirm whether or not they want to allow the application to exit when a
click through URL is to be displayed outside of the current application space. This
feature is disabled by default.
When enabled, the popup confirmation occurs for the following scenarios:
When the local landing page feature is not enabled.
When the local landing page feature is enabled but cannot display the click
through URL for reasons cited in the Local Landing Page section above.
The following example illustrates how to enable the application confirmation exit
feature from within the application delegate class. This is a global setting that
applies to all VeltiView instances.
Enabling the image creative auto sizing feature causes an image creative to be
automatically sized to fit within the space allocated for a given VeltiView instance.
Note the following auto sizing behavior:
Occurs only when a single creative exist within an ad unit. For example, if
auto sizing is enabled and an ad unit consists of a banner and text, the
banner is not resized.
Maintains horizontal and vertical aspect ratios.
Occurs only when the image dimensions are less than the dimensions
allocated for the VeltiView instance.
The following example illustrates how to enable the image creative auto sizing
feature for a given VeltiView instance. It is recommended to enable animations
when using the auto sizing feature such that a smooth transition is provided when
displaying an advertisement. Note that this property must be specified before the
ad request is invoked.
[veltiView setEnableImageCreativeAutosizing:TRUE];
8.6 Language
The two letter ISO language code may be specified for each VeltiView instance
which is provided to the server during an ad request. As such, advertisements may
be created for the SDK which target a specific language.
The following example illustrates how to specify the language code. Note that this
property must be specified before the ad request is invoked.
[veltiView setLanguage:@"en"];
A test mode is available which is useful to verify successful integration with the
SDK while also simulating the following features:
Advertisement Display
Statistics Tracking
Click-to-Action
Test mode is executed remotely to the simulator or device and makes all requests
using demo servers. The following example illustrates how to enable test mode
from within the application delegate class.
[[VeltiManager sharedInstance] setTestMode:TRUE];
9.1 What is the Velti iPhone SDK compatibility with iPhone SDK versions?
The following table provides a listing of the SDK version and the corresponding
compatible iPhone SDK version.
9.2 How do I know what version of the Velti iPhone SDK I'm using?
Expand the VeltiSDKResource.bundle and select the Info.plist file. Locate the
‘Bundle versions string, short’ and ‘Bundle version’ Keys whose value column
contain the version and build number respectively as shown in the following
screenshot. Alternatively, you can invoke getVersion or getBuildNumber from the
VeltiManager singleton instance.
By default, when a VeltiView instance is allocated with a frame that is larger than
the image creative that it contains following an ad request, the image creative is
not automatically resized to fit within the VeltiView. The reason for this design
choice is to avoid scenarios whereby undesirable loss of image quality may occur
during resizing and thus the original size of the image creative is always respected.
However, the image creative auto size feature may be enabled for a given
VeltiView instance. For more information, see the Additional Features section
above.
10 Class Reference
The links below provide navigation to the API html documents that accompany the
Velti iPhone SDK and are presented in the default browser. Note that this document
must reside in the same directory as the other contents in the docs folder in order
for the links to be navigable from this document.
VeltiView.h
VeltiManager.h