workshop: integrating amazon apis in unity
TRANSCRIPT
@peterdotgames peterhe inr ic h
I NTEGRAT ING AMAZ ON AP I s IN UN ITY
PETER HE INR ICHD E V E L O P E R E V A N G E L I S T , A M A Z O N
AGENDA
A M A Z O N A P I s A C C O U N T S E T U P M O B I L E A D S A M A Z O N F L I N G
AD
AGENDA
A M A Z O N A P I s A C C O U N T S E T U P M O B I L E A D S A M A Z O N F L I N G
AD
AMAZON APIs
C U S TO M E R O B S E S S E D
Start with the customer
and work backwards.
J e f f B e z o s
A P P S TO R E V I S I O N
Our vision is to connectcontent creators and customers through apps, games, and experiences that create value and delight.
ANDROID PHONES & TABLETS
FIRE TV & FIRE TV STICK
BLACKBERRYFIRE TABLETS
A P I s
Login with AmazonIn-App Purchasing
Mobile Ads
GameCircle
Amazon Fling AD
Amazon Maps Device Messaging
Amazon Drive
A P I s
In-App Purchasing
Mobile Ads
GameCircle
Amazon Fling AD
Amazon provides support for
AGENDA
A M A Z O N A P I s A C C O U N T S E T U P M O B I L E A D S A M A Z O N F L I N G
AD
ACCOUNT SET UP
D E V E L O P E R P O RTA L
D E V E L O P E R P O RTA L
D E V E L O P E R P O RTA L
D E V E L O P E R P O RTA L
D E V E L O P E R P O RTA L http://bit.ly/AppstoreSDK
AGENDA
A M A Z O N A P I s A C C O U N T S E T U P M O B I L E A D S A M A Z O N F L I N G
AD
MOBILE ADS
AD
M O B I L E A D S
MONETIZATION ACROSS PLATFORMS/ APPSTORES
Multiple ad formats optimised for Fire OS, Android, and iOS operating systems
Great eCPM – get paid on ad impressions served instead of clicks on ads
Highly relevant mobile optimized ads from Amazon and high quality brands
D E TA I L S
AD
M O B I L E A D S
• Static Banners
• Rich Media Banners
• Static Interstitials
• Modeless Interstitials
• Rich Media Interstitials (includes click-to-play video)
ADDING THE UNITY PLUGINAD
ADDING THE UNITY PLUGINAD
ADDING THE UNITY PLUGINAD
D E V E L O P E R P O RTA L
D E V E L O P E R P O RTA L
D E V E L O P E R P O RTA L
using com.amazon.mas.cpt.ads;
// Obtain object used to interact with the plugin
IAmazonMobileAds mobileAds = AmazonMobileAdsImpl.Instance;
public string androidKey = "d914c248d27248d19cdd26039bf5846d";
public string iosKey = "9cdd26039bf5846dd914c248d27248d1";
// Construct object passed to sync operation as input
ApplicationKey key = new ApplicationKey();
// Use Android app key for Android apps and iOS
// app key for iOS apps
#if UNITY_ANDROID
key.StringValue = androidKey;
#elif UNITY_IPHONE
key.StringValue = iosKey;
#endif
// Call method, passing in required input structure
// This method does not return a response
mobileAds.SetApplicationKey( key );
S E T T H E A P P L I C AT I O N K E Y ( S )
using com.amazon.mas.cpt.ads;
public void EnableTesting() {
// Obtain object used to interact with the plugin
IAmazonMobileAds mobileAds = AmazonMobileAdsImpl.Instance;
// Construct object passed to sync operation as input
ShouldEnable enable = new ShouldEnable();
// Set input value
enable.BooleanValue = true;
// Call method, passing in required input structure
// This method does not return a response
mobileAds.EnableTesting( enable );
mobileAds.EnableLogging( enable );
}
E N A B L E T E S T I N G A N D L O G G I N G
<manifest ...>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
...
<application ...>
<activity android:name="com.amazon.device.ads.AdActivity"
android:configChanges="keyboardHidden|orientation|screenSize"/>
...
</application>
</manifest>
AndroidManifest.xml
using com.amazon.mas.cpt.ads;
public void DisplayFloatingAd() {
// Obtain object used to interact with the plugin
IAmazonMobileAds mobileAds = AmazonMobileAdsImpl.Instance;
// Configure the placement of the ad
Placement placement = new Placement();
placement.Dock = Dock.TOP;
placement.HorizontalAlign = HorizontalAlign.CENTER;
placement.AdFit = AdFit.FIT_AD_SIZE;
// This method returns an Ad object, which you must save and keep track of
Ad response = mobileAds.CreateFloatingBannerAd( placement );
// Now that the ad has been created, load it and show it on the screen
LoadingStarted loadResp = mobileAds.LoadAndShowFloatingBannerAd( response );
}
C R E AT E A N D D I S P L AY A T E S T A D
using com.amazon.mas.cpt.ads;
// Define event handlers
private void HandleAdLoaded( Ad args ) {
string adType = args.AdType.ToString();
long identifier = args.Identifier;
// Do something. . .
}
private void HandleAdFailedToLoad( Ad args ) {
string adType = args.AdType.ToString();
long identifier = args.Identifier;
// Do something. . .
}
// Register for the events
mobileAds.AddAdLoadedListener( HandleAdLoaded );
mobileAds.AddAdFailedToLoadListener( HandleAdFailedToLoad );
R E G I S T E R I N G F O R E V E N T S
TO I N I T I AT E A M E T H O D C A L L
Obtain the object used to interact with the plugin.
S U M M A RY
If needed, construct the object used to pass input to the operation.
For asynchronous operations, define a callback function that is invoked when a response is ready.
Call the operation, passing in any required input and/or callback function as arguments.
AD
IAmazonMobileAds mobileAds =
AmazonMobileAdsImpl.Instance;
Placement placement = new Placement();
placement.Dock = Dock.TOP;
private void HandleAdLoaded( Ad args ) {
// Do something. . .
}
mobileAds.SetApplicationKey( key );
Example:
AGENDA
A M A Z O N A P I s A C C O U N T S E T U P M O B I L E A D S A M A Z O N F L I N G
AD
AMAZON FLING
A M A Z O N F L I N G
BUILD RICH MULTI-SCREEN EXPERIENCES
Cross platform toolkit that enables you to build rich multi-screen experiences for Fire TV
Allows sending video, audio and images from iOS, Android, or Fire OS
Leverage two-way communication between Amazon Fire TV and mobile apps to create engaging second screen experiences
D E TA I L S
using com.amazon.whisperplay.fling.cpt.media.controller;
using com.amazon.whisperplay.fling.cpt.media.controller.json;
void Start () {
deviceList = new SortedList<string, Player>();
if (flingService == null) {
flingService = AmazonFlingServiceImpl.Instance;
OnResume();
}
// Register event handlers
flingService.AddPlayerDiscoveredListener( PlayerDiscovered );
flingService.AddPlayerLostListener( PlayerLost );
flingService.AddDiscoveryFailureListener( DiscoveryFailure );
flingService.AddOnStatusChangeListener( OnStatusChange );
// Load resources to display catalog of available media. . .
}
I N I T I A L I Z E T H E S E RV I C E
private void PlayerDiscovered( Player args ) {
deviceList.Add( args.PlayerId, args );
if( previousPlayer != null && args.PlayerId == previousPlayer.PlayerId ) {
SetDevice( args );
}
if( showDeviceMenu ) {
CreatePickerList();
}
}
private void PlayerLost( Player args ) {
deviceList.Remove(args.PlayerId );
if( showDeviceMenu ) {
CreatePickerList();
}
}
E V E N T H A N D L E R S
A D D I T I O N A L D E P L O Y M E N T S T E P S
i O S A N D R O I D
1. In Xcode, select your Xcode project root.
2. Select the target Unity-iPhone.
3. Click the Build Phases tab.
4. Open the Link Binary with Libraries foldout.
5. Cluck the + at the bottom of the this foldout.
6. Add all the frameworks and libraries required by the SDK:
1. AmazonFling.framework
2. Bolts.framework
3. AdSupport.framework
4. Security.framework
5. Libc++.dylib
7. Follow iOS SDK’s specific guidelines for importing dependencies.
1. Add these android.permission values to your manifest:
On Fire OS & Android:
INTERNET
ACCESS_WIFI_STATE
ACCESS_NETWORK_STATE
On Android only:
CHANGE_WIFI_MULTICAST_STATE
2. On Fire OS only, add this line to the application section of Plugins/Android/AndroidManifest.xml(and remove the Plugins/Android/WhisperPlay.jar):
<uses-library android:name=
"com.amazon.whisperplay.contracts" />
http://bit.ly/FlingSteps
WHERE DO WE GO
FROM HERE?
W H E R E D O W E G O F R O M H E R E ?
N E X T S T E P S
CREATE YOUR
DEVELOPER ACCOUNT PUBLISH!BUILD YOUR APP
REVIEW DEV
PORTAL RESOURCES
NEW
developer.amazon.com/public
Peter Heinrich@peterdotgames
@AmazonAppDev
developer.amazon.com/appstore
THANK YOU!
bit.ly/AmazonSummitFeedback