IOS
Contents |
Publishers
Download iOS SDK
Download the [iOS SDK for publishers]. Decompress the zip file and extract the files to your development mac.
The Ad4game iOS SDK is provided as a single framework file (A4GPub.framework), making it easy to include in your iOS project.
Include the A4GPub.framework
To include the A4GPub.framework to your xcode project, you need to select your target project, and then go to Build Phases → Link Binary With Libraries,
then click on the + sign → Add Other, and select the A4GPub.framework saved on your mac as shown below:
Include the AdSupport.framework
You need to include the AdSupport.framework to your project target to enable the Advertiser Identifier functionality. Go to Build Phases → Link Binary With
Libraries, then click on the + sign to add the AdSupport.framework as shown below:
Then, change the value of AdSupport.framework from Required to Optional.
Include the SystemConfiguration.framework
You need to include the SystemConfiguration.framework to your project target to enable detection of the connection type. Go to Build Phases → Link Binary With Libraries, then click on the + sign to add the SystemConfiguration.framework.
Include the QuartzCore.framework
You need to include the QuartzCore.framework to your project target to customize the interface.
Go to Build Phases → Link Binary With Libraries, then click on the + sign to add the QuartzCore.framework.
Display Mobile Ads
To display ads on your iOS project, you need to follow the steps bellow:
In your ViewController.xib
– You need to add an UIImageView with the size of the ad.
– You need to add an UIButton above the UIImageView with the same size of the ad.
Connect the UIImageView and the UIButton to your ViewController.h file.
In your ViewController.h file
– You need to import the A4GPub.framework.
– Declare an Object of A4GPubViewController.
Your code need to be similar to this:
In your ViewController.m file
– You need to import the A4GPub.framework.
– In your viewDidLoad method, you need to instantiate the object created on viewController.h file and call the different method to display ads.
The methods are:
* setZoneID method allows you to set the zoneID.
* setImageView method allows you to set your UIImageView.
* getRefresh method to refresh the display of banners.
* loadAds method to get banners from ad4game servers.
Your code need to be similar to this:
– In your (IBAction)button : (id)sender method, you need to call the loadClick method allowing you to get the click associate to the ad displayed.
In your ViewController.h :
In your ViewController.m :
Display iOS Editorials
To display iOS Editorials on your iOS project, you need to follow the steps bellow:
In your ViewController.xib
You need to add a UIButton if you want to launch the editorials when the user clicks on that button.
Connect the UIButton to your ViewController.h file.
In your ViewController.h file
– You need to import the A4GEdito.h header file.
– Declare an Object of A4GEdito.
Your code need to be similar to this:
In your ViewController.m file
– In your viewDidLoad method, you need to instantiate the object created on your ViewController.h file and call the different method to display Editorials.
The methods are:
* setZoneID method, allows you to set the zoneID.
* setButton method, allows you to set your UIButton.
* showA4GEditos method, to display directly the Editorials when the app started.
* showA4GEditosWithStartTime method, to display the Editorials after a certain time.
* showA4GEditosWithStartAndEndTime method, to display the Editorials after a certain time, and close them automatically after a certain time.
Your code need to be similar to this:
Advertisers
Download Android SDK
Download the [Android SDK for advertisers]. Decompress the zip file and extract the files to your development computer.
The Android SDK is provided as a single java JAR file (AndroidSDKTracker.jar), making it easy to include in your Android project.
Install the Android SDK
Add AndroidSDKTracker.jar to your Android project's build path.
If you are using Eclipse, right click on your project folder > Properties > Java Build Path > Libraries > Add JARs.
(As of ADT 17.0, you can simply place AndroidSDKTracker.jar in a folder called “libs” in your project directory and Eclipse will automatically include the jar as part of the build under the classpath container “Android Dependencies”) .
Configure AndroidManifest.xml
The SDK requires the following permissions. Put these in before closing the manifest tag.
Internet Permission (Mandatory):
The Internet permission is required to connect to tracking servers.
<uses-permission android:name="android.permission.INTERNET"/>
Wifi State Permission (Mandatory):
This permission enable the SDK to access information about whether you are connected to a WiFi network and obtain the device’s MAC address.
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
Connection State Permission (Mandatory):
This permission enable the SDK to track installations when the user is connected to internet.
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Unique Device Identifier (Mandatory):
Allows the SDK to get a unique id per device. Put these lines before closing the application tag.
<application ...> <activity ...> ... </activity> <service android:name="org.openudid.A4GOpenUDID_service"> <intent-filter> <action android:name="org.openudid.GETUDID" /> </intent-filter> </service> </application>
The SDK requires setting up a Tracker receiver in your Android manifest. Put this receiver inside your application tags.
Install Referral (Required):
Gives the SDK access to the install referrer value from Google Play Store.
<receiver android:name="com.mypackage.MyReceiverClass" android:exported="true">
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intentfilter>
</receiver>
You need to create your ReceiverClass as follow:
yourReceiverClass extends the BroadcastReceiver. Inside the onReceive method, you need to instantiate the A4GTracking class, and then call the trackInstall method which has these parameters trackerID, context and intent.
public class MyReceiverClass extends BroadcastReceiver{
public void onReceive(Context context, Intent intent) {
//Begin of tracking installs
A4GTracking a4g = new A4GTracking(context);
a4g.trackInstall("yourTrackerID", context, intent);
// End of tracking installs
}
}
In your onCreate method, you need to instantiate the A4GTracking class to allow you to call the functions from the AndroidSDKTracker.
public class MyActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Begin of tracking installs
//Instantiate the A4GTracking class
A4GTracking a4g = new A4GTracking(getApplicationContext());
a4g.trackInstall("yourTrackerID", getApplicationContext(), null);
// End of tracking installs
}
}