workshop: integrating amazon apis in unity

42
@ peterdotgames peterheinrich INTEGRATING AMAZON APIs IN UNITY PETER HEINRICH DEVELOPER EVANGELIST, AMAZON

Upload: amazon-appstore-developers

Post on 11-Feb-2017

38 views

Category:

Mobile


0 download

TRANSCRIPT

Page 1: Workshop: Integrating Amazon APIs in Unity

@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

Page 2: Workshop: Integrating Amazon APIs in Unity

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

Page 3: Workshop: Integrating Amazon APIs in Unity

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

Page 4: Workshop: Integrating Amazon APIs in Unity

AMAZON APIs

Page 5: Workshop: Integrating Amazon APIs in Unity

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

Page 6: Workshop: Integrating Amazon APIs in Unity

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.

Page 7: Workshop: Integrating Amazon APIs in Unity

ANDROID PHONES & TABLETS

FIRE TV & FIRE TV STICK

BLACKBERRYFIRE TABLETS

Page 8: Workshop: Integrating Amazon APIs in Unity

A P I s

Login with AmazonIn-App Purchasing

Mobile Ads

GameCircle

Amazon Fling AD

Amazon Maps Device Messaging

Amazon Drive

Page 9: Workshop: Integrating Amazon APIs in Unity

A P I s

In-App Purchasing

Mobile Ads

GameCircle

Amazon Fling AD

Amazon provides support for

Page 10: Workshop: Integrating Amazon APIs in Unity

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

Page 11: Workshop: Integrating Amazon APIs in Unity

ACCOUNT SET UP

Page 12: Workshop: Integrating Amazon APIs in Unity

D E V E L O P E R P O RTA L

Page 13: Workshop: Integrating Amazon APIs in Unity

D E V E L O P E R P O RTA L

Page 14: Workshop: Integrating Amazon APIs in Unity

D E V E L O P E R P O RTA L

Page 15: Workshop: Integrating Amazon APIs in Unity

D E V E L O P E R P O RTA L

Page 16: Workshop: Integrating Amazon APIs in Unity

D E V E L O P E R P O RTA L http://bit.ly/AppstoreSDK

Page 17: Workshop: Integrating Amazon APIs in Unity

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

Page 18: Workshop: Integrating Amazon APIs in Unity

MOBILE ADS

AD

Page 19: Workshop: Integrating Amazon APIs in Unity

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

Page 20: Workshop: Integrating Amazon APIs in Unity

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)

Page 21: Workshop: Integrating Amazon APIs in Unity

ADDING THE UNITY PLUGINAD

Page 22: Workshop: Integrating Amazon APIs in Unity

ADDING THE UNITY PLUGINAD

Page 23: Workshop: Integrating Amazon APIs in Unity

ADDING THE UNITY PLUGINAD

Page 24: Workshop: Integrating Amazon APIs in Unity

D E V E L O P E R P O RTA L

Page 25: Workshop: Integrating Amazon APIs in Unity

D E V E L O P E R P O RTA L

Page 26: Workshop: Integrating Amazon APIs in Unity

D E V E L O P E R P O RTA L

Page 27: Workshop: Integrating Amazon APIs in Unity

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 )

Page 28: Workshop: Integrating Amazon APIs in Unity

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

Page 29: Workshop: Integrating Amazon APIs in Unity

<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

Page 30: Workshop: Integrating Amazon APIs in Unity

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

Page 31: Workshop: Integrating Amazon APIs in Unity
Page 32: Workshop: Integrating Amazon APIs in Unity

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

Page 33: Workshop: Integrating Amazon APIs in Unity

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:

Page 34: Workshop: Integrating Amazon APIs in Unity

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

Page 35: Workshop: Integrating Amazon APIs in Unity

AMAZON FLING

Page 36: Workshop: Integrating Amazon APIs in Unity

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

Page 37: Workshop: Integrating Amazon APIs in Unity

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

Page 38: Workshop: Integrating Amazon APIs in Unity

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

Page 39: Workshop: Integrating Amazon APIs in Unity

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

Page 40: Workshop: Integrating Amazon APIs in Unity

WHERE DO WE GO

FROM HERE?

Page 41: Workshop: Integrating Amazon APIs in Unity

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

Page 42: Workshop: Integrating Amazon APIs in Unity

Peter Heinrich@peterdotgames

@AmazonAppDev

[email protected]

developer.amazon.com/appstore

THANK YOU!

bit.ly/AmazonSummitFeedback