A library that provides tools for adding ads to your iOS apps using the TradeIt platform.
Follow the Cocoapods: Getting started guide and Cocoapods: Using Cocoapods guide if you've never used Cocoapods before.
Inside your Podfile
you need to add the TradeIt spec repo as a source:
source 'https://github.com/tradingticket/SpecRepo'
Under your project target add our Ticket SDK pod as a dependency:
pod 'TradeItIosAdSdk', '~> 0.2.0'
This is a base example of what it should look like:
source 'https://github.com/tradingticket/SpecRepo'
target 'YourProjectTargetName' do
use_frameworks!
pod 'TradeItIosAdSdk', '~> 0.2.0'
end
- Add
import TradeItIosAdSdk
to your imports - Set the API key with
TradeItAdConfig.apiKey = ""
when your application loads, before any ads are displayed. Your AppDelegate'sappDidFinishLaunching
is the recommended place. - Set the environment with
TradeItAdConfig.environment = .qa
while in development and then switch to.prod
for release
- Add
#import <TradeItIosAdSdk/TradeItIosAdSdk-Swift.h>
to your imports - Set the API key with
TradeItAdConfig.apiKey = "";
when your application loads, before any ads are displayed. Your AppDelegate'sappDidFinishLaunching
is the recommended place. - Set the environment with
TradeItAdConfig.environment = TradeItEnvironmentQa;
while in development and then switch toTradeItEnvironmentProd
for release
- Add a
UIView
to the view where the ad should appear - Set the
UIView
to be of classTradeItAdView
and moduleTradeItAdSdk
on theIdentity Inspector
- Add
Trailing
andLeading
constraints to the new view - Set the constant to
0
for both constraints - Remove
Relative to Margin
for both constraints so that it stretches the entire width of the device - Add a
Height
constraint to the new view - Set the constant to
50
for the height constraint - Create
IBOutlet
s for both theadView
andadViewHeightConstraint
If the user is logged in, you must pass the User information to TradeItAdConfig
so that tracking works correctly.
TradeItAdConfig.users = [
[ "userId": "account-1", "userToken": "token-account-1" ],
[ "userId": "account-2", "userToken": "token-account-2" ]
]
If you are integrated with the current Objective-C TradeIt Trading Ticket mobile SDK, you can generate this using the following snippet.
TradeItConnector * connector = [[TradeItConnector alloc] initWithApiKey:TradeItAdConfig.apiKey];
NSArray *linkedLogins = [connector getLinkedLogins];
NSMutableArray *users = [[NSMutableArray alloc] init];
for (TradeItLinkedLogin *linkedLogin in linkedLogins) {
NSString *userToken = [connector userTokenFromKeychainId:linkedLogin.keychainId];
if (userToken.length > 0) {
NSDictionary *user = @{ @"userId": linkedLogin.userId, @"userToken": userToken };
[users addObject:user];
}
}
TradeItAdConfig.users = users;
There are helpers for configuring the view. Only the Ad Type is required.
// Ad Type
adView.configure(withAdType: "general")
// Ad Type and Broker
adView.configure(withAdType: "general", broker: "Dummy")
// Ad Type and Height Constraint
adView.configure(withAdType: "general", heightConstraint: adViewHeightConstraint)
// Ad Type, Broker and Height Constraint
adView.configure(withAdType: "general", broker: "Dummy", heightConstraint: adViewHeightConstraint)
AdType | Description |
---|---|
account |
An ad to display when the user is linking, editing or removing a broker. |
portfolio |
An ad to display when user is viewing positions, balances, order status or transactions. |
ticket |
An ad to display while the user is entering an order on the Trading Ticket. |
tradeConfirmation |
An ad placed when a trade has been successfully placed. |
general |
A short ad to display anywhere else within your app (i.e, home screen, quote screen, news screen). |
Provide the broker
if the user is interacting with a particular broker.
This allows ads to be targetted to the broker.
For example, if a user is on their Fidelity portfolio screen then pass the parameter "Fidelity".
Provide the heightConstraint
so that the view height can be adjusted.
If the ad is a different size to the size you have set up, it will be adjusted to fit the ad content.
If ads are disabled or the request to the ad server fail the ad view collapses to 0 height.
The SDK includes an example Swift app target. To run, switch to the Example App
target and click run.
Default: TradeItAdEnvironment.prod
Determines which TradeIt environment to hit. This can be set to .prod
or .qa
.
Default: false
If true
it will log debugging information about the ad requests and device querying to the xcode console.
Default: true
If false
it will hide the ad views.