-
Notifications
You must be signed in to change notification settings - Fork 0
Custom Events
Custom Events are notifications sent to your app, which can be used to trigger code logic implemented by your AdFlakeDelegate
(iOS) or AdFlakeListener
(Android).
Custom Events can be used to trigger anything, here are a few examples to get your imagination flowing:
- Incorporate ad networks that are not directly supported by AdFlake.
- Invoke analytics tracking
- Randomly reward users
- Request user rating on the App Store
- Display interstitial banners
- Trigger any other code
Custom Events are easily setup in the AdFlake backend, as regular ad networks and house ads, you have to assign certain portion of your traffic to custom events.
Create your first Custom Event by browsing to your AdFlake home page and selecting the app that will use the custom event.
Click Custom Events
from the sidebar displayed on the left side of the page.
Click Add New Event
display inside the table on the right side of the custom events detail page.
A form will popup that enables you to enter an event name
as well as a method.
The event name is used internally in the system to identify the custom event.
The method is the name of the method that will be invoked on your AdFlakeDelegate
(iOS) or your AdFlakeListener
(Android).
The method name specified here must match the method name in the code, if it does not match your application will not crash, but the custom event will not be invoked.
If you want to follow this tutorial, enter Test Event
as event name and didReceiveTestEvent
as event method.
Enter 100% as allocation, as with house ads, you can specify separate allocations for each of your custom events. The total custom event allocation (as setup on the active ad networks page) will be distributed to your custom events according to their allocations.
Press Save
to save the custom event.
Once you have created your custom event, click on the Ad Networks
button in the sidebar displayed on the left side of the page.
Locate the Custom Events
table row and click the Setup
button and enable the Active
checkbox.
Finally, setup an allocation. In this tutorial we'll only enable custom events, thus we set the global custom events allocation to 100%.
Click Save
when you have activated custom events.
Custom events on iOS are sent to your AdFlakeDelegate
, thus you have to implement your custom event handling inside your delegate. Open the class implementation file that implements the AdFlakeDelegate
protocol. And implement a method (without parameters) with the name of your event method. If you're following along this tutorial, the name of the method is didReceiveTestEvent
.
- (void) didReceiveTestEvent
{
NSLog(@"We've received the test event from AdFlake! That's awesome!");
}
That's it! Now build and run your app. Make sure that you have your SDK keys setup properly and an AdFlakeView
added to your view hierarchy.
Custom events on Android are invoked on your AdFlakeListener
, thus you have to implement your custom event handling inside your listener class. Open the class implementation file that implements the AdFlakeListener
interface. And implement a method (without parameters) with the name of your event method. If you're following along this tutorial, the name of the method is didReceiveTestEvent
.
If you haven't assigned an AdFlakeListener
yet, we recommend setting it to your Activity
adWhirlLayout.setAdWhirlInterface(this);
Let Eclipse do all the fixing, and add the AdFlakeListener
interface to your Activity
and implement all methods.
Now implement your custom event's method in your 'AdFlakeListener'. If you're following along this tutorial, the name of the method is didReceiveTestEvent
.
public void didReceiveTestEvent()
{
Log.e(AdFlakeUtil.ADFLAKE, "We've received the test event from AdFlake! That's awesome!");
}
That's it! Now build and run your app. Make sure that you have your SDK keys setup properly and an AdFlakeLayout
added to your view layout.