Jump to: navigation, search

Adobe AIR (1.38)

NoteBubble.png

Important: Please test your integration on an iOS or Android device. Many API features, including ads, will ONLY work on a device.

Downloading the SDK

Before starting integration, you'll need to download the latest version of the Fuse SDK specific to your development environment. You can download the Air Native Extension for FuseAPI Here.

Fuse AIR Sample App

The Fuse AIR Sample app is a great reference for getting started. Sample projects exist for both Flash Builder and Flash CC:

Builder 4.7 Project

Flash CC Project

Using Flash CC

To integrate the plugin into your Flash project follow theses steps:

Installation 1.png

Copy the AirFuseAPI.ane and AirFuseAPI.swf files into your project.

Installation 2.png

In Flash, navigate to: File -> Air for iOS settings -> General, and in the "Include files" list, add an entry and choose the AirFuseAPI.ane file, located in the bin folder. Once you have it included, click OK.

Installation 3.png

Navigate to: File -> ActionScriptSettings -> Library Path.

Installation 4.png

Click the button to "Browse to a Native Air Extension (ANE file)", and select the AirFuseAPI.ane file.


To use the AirFuseAPI plugin in your Flash project, you must import the Fuse package:

import com.fuse.ane.*;

Using Flash Builder 4.6+

1. Download the Fuse Adobe AIR SDK

2. In your Flash Builder project, import the AirFuseAPI.ane and AirFuseAPI.swc:

a. Navigate to the ActionScript Build Path section of the Properties window for your Flash Builder project and select the Library path tab.

Air.png

b. Click on ‘Add SWC…’ and browse to the path where you downloaded the Fuse AIR SDK and select the AirFuseAPI.swc file.

c. Next, go to the Native Extensions tab in the Properties window.

Air2.png

d. Click on ‘Add ANE…’ and browse to the path where you downloaded the Fuse AIR SDK and select the AirFuseAPI.ane file.

NOTE: You may see an error similar to “This ANE does not support Desktop(Mac) platform”. This error can be safely disregarded. The Fuse AIR API will only properly initialize on mobile devices.

3. You can start by downloading the FuseAdapter.as class here to quickly get some features integrated.

To initialize the FuseAdapter class, in your main method call:

 FuseAdapter.initialise();

Android Manifest

NoteBubble.png

If you are developing for Android, you must add these changes to your Android Manifest file

Permissions

The following permissions should be included within the manifest tags.

   <uses-sdk
          android:minSdkVersion="11"
          android:targetSdkVersion="16" />
      <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
      <uses-permission android:name="android.permission.INTERNET" />
      <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
      <uses-permission android:name="com.android.vending.BILLING" />
      <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

The following permissions are optional but can greatly improve ad performance.

  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

Activities

Fuse activities must be configured in the Main-app.xml file. The following activities must be included under your application tag.

       <receiver android:name="com.fusepowered.push.FusePushNotificationReceiver" 
                       android:permission="com.google.android.c2dm.permission.SEND" >
         <intent-filter>
           <action android:name="com.google.android.c2dm.intent.RECEIVE" />
           <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
           <category android:name="<Application Package>" />
         </intent-filter>
       </receiver>
       <receiver android:name="com.google.android.c2dm.C2DMBroadcastReceiver"
       android:permission="com.google.android.c2dm.permission.SEND">
       <intent-filter>
           <action android:name="com.google.android.c2dm.intent.RECEIVE" />
           <category android:name="com.my.package" /> 
       </intent-filter>
       <intent-filter>
           <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
           <category android:name="com.my.package" /> 
       </intent-filter>
       </receiver>
       <service android:name="com.fusepowered.push.FuseIntentService" />
       <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
       <activity
           android:name="com.fusepowered.m2.mobileads.M2Activity"
           android:configChanges="keyboardHidden|orientation" />
       <activity
           android:name="com.fusepowered.m2.mobileads.M2RActivity"
           android:configChanges="keyboardHidden|orientation" />
       <activity
           android:name="com.fusepowered.m2.common.M2Browser"
           android:configChanges="keyboardHidden|orientation" />
       <activity
           android:name="com.fusepowered.m2.mobileads.M2RvpActivity"
           android:configChanges="keyboardHidden|orientation" />
       <activity
           android:name="com.fusepowered.m1.android.MMActivity"
           android:configChanges="keyboardHidden|orientation|keyboard"
           android:theme="@android:style/Theme.Translucent.NoTitleBar" />
       <activity
           android:name="com.fusepowered.m1.android.VideoPlayer"
           android:configChanges="keyboardHidden|orientation|keyboard" />
       <activity
               android:name="com.fusepowered.a1.A1InterstitialActivity"
               android:configChanges="keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize"
               android:hardwareAccelerated="true"
               android:theme="@android:style/Theme.NoTitleBar.Fullscreen" />
       <activity
               android:name="com.fusepowered.u1.U1InterstitialActivity"
               android:configChanges="keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize"
               android:hardwareAccelerated="true"
               android:theme="@android:style/Theme.NoTitleBar.Fullscreen" />
       <activity android:name="com.fusepowered.s1.S1InterstitialActivity" android:hardwareAccelerated="true"/>
       <activity
               android:name="com.fusepowered.ads.FuseInterstitialActivity"
               android:configChanges="keyboardHidden|orientation|screenSize"
               android:noHistory="true"
               android:theme="@style/Theme.transparent" >
       </activity>
       <activity
           android:name="com.fusepowered.l1.AdActivity"
           android:configChanges="orientation|keyboardHidden|screenSize"
           android:hardwareAccelerated="true" />
       <activity
           android:name="com.fusepowered.l1.AdBrowserActivity" />
       <activity
           android:name="com.fusepowered.l1.PlayerActivity"
           android:configChanges="orientation|keyboardHidden|screenSize"
           android:hardwareAccelerated="true" />
       <activity android:name="com.fusepowered.ac.ACOActivity"
       android:configChanges="keyboardHidden|orientation|screenSize"
       android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
       <activity android:name="com.fusepowered.ac.ACFActivity"
       android:configChanges="keyboardHidden|orientation|screenSize"
       android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" />
       <activity android:name="com.fusepowered.ac.ACBActivity"
       android:configChanges="keyboardHidden|orientation|screenSize"
       android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" />
       <activity android:name="com.fusepowered.ads.providers.LRActivity"
                 android:configChanges="keyboardHidden|orientation|screenSize"
                 android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" />
       <activity android:name="com.fusepowered.sa.android.publish.list3d.List3DActivity"
         android:theme="@android:style/Theme" />
       <activity android:name="com.fusepowered.sa.android.publish.AppWallActivity"
         android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
         android:configChanges="orientation|keyboardHidden|screenSize" />

You can find more information on styles Here.

External Adapters

For optimal performance, we have included three external adapters for developers to use; AdColony, HyprMX, and AppLovin. To use these adapters, which is highly recommended, you need to add the following lines to your application xml file in the extensions section:

 <extensionID>com.fuse.AdColony</extensionID>
 <extensionID>com.fuse.HyprMX</extensionID>
 <extensionID>com.fuse.AppLovin</extensionID>

Starting a Session

Overview

The very first thing you'll have to do is register the start of a session using the start session function. This tells our servers that a session has begun, and will immediately begin tracking session information. By passing your app's assigned API key to the start session function, it will authenticate your application with the Fuse servers.

You will want to call startSession as soon as your app is initialized.

Integration

public class YourApp extends app {
     fuse = new AirFuseAPI();
     fuse.startSession('<YOUR FUSE API KEY>');
}

Your API key is generated when you add your app to AdRally™. It can be found in the configuration tab in a specific game, or the (Admin>Integrate SDK>Your API Keys) section of AdRally™. The API key is a 36-digit unique ID.


Showing Ads

NoteBubble.png

Before your App goes live you must configure your Zones, for more information see Here

Checking Ad Availability

When working with Adobe AIR, calling the checkAdAvailable method and passing an empty string for Zone Name check if an ad is available for the default zone. Passing in a string will check if an ad is available for the zone named by the string.

The callback function should take two integer type parameters:

- The first one is 1 when there is an ad available and 0 when there isn't.

- The second one is the error code and is 0 when there are no errors. For connectivity issues the error code will be 1 and for session errors it will be 2.


 FuseAPI.checkAdAvailable(callback, "Zone Name")

Pre-Loading Ads

preloadAdForZone works the same way, except that there is no delegate. Passing an empty string pre loads for default zone, while passing a non-empty string pre loads for a specific zone. We recommend calling preloadAdForZone two or three seconds before calling show ad.

 FuseAPI.preloadAdForZone("zone name")


Calling preloadAdForZone is not mandatory, but it has a number of benefits, including the fact that it is less aggressive with timing out, allow for more opportunity to return higher paying ads.

Displaying Ads

Once you've checked the availability of a particular ad zone, you can show the ad using the method below.

 FuseAPI.showAd(callback, "zone name")

Passing an empty string shows default zone. Passing a non-empty string shows that zone, or pushes it to the dashboard.

The callback used in this function doesn't have any arguments and will be executed when the ad has been closed.

Tracking In App Purchases

You can use the following code block to track IAPs on adobe air, you must provide the parameters for the call.

 function yourInAppPurchaseHandler():void 
 {
   var os = Capabilities.manufacturer;
   var is_ios:Boolean = os.indexOf('iOS') > -1;
   
   var state:String;
   var product_id:String;
   var transaction_id:String;
   var price:String = '0.99';
   var currency:String = 'USD';
               
   if (is_ios)
   {
       // ios
       var receipt:String;
       
       state = '1'; // conforms to enum SKPaymentTransactionState: 
       //https://developer.apple.com/library/ios/documentation/StoreKit/Reference/SKPaymentTransaction_Class/Reference/Reference.html
       product_id = 'com.yourcompany.product.id.freddyfunbucks';
       transaction_id = '170000129449420';
       
       receipt = <Your Receipt Here>
 
       fuse.registerInAppPurchase(this.inAppPurchaseResponse, state, 
                 price, currency, product_id, transaction_id, receipt);
   }
   else
   {
       // android
       var token:String;
       
       state = 'purchased';
       product_id = 'com.yourcompany.product.id.freddyfunbucks';
       transaction_id = '1234623462246316867';
       token = 'edtmztenfapydmhjqnzeofjg.Fi0l41h4c381xf-_oU1pqGWnvdptLtcVpT9kTbVsNkO_u6lKYQ1mwD3f-5f8-cHl1qbAe79Ae7H6T5jO7U801udVFfyz3iPs18LQC5ohDvWLnoam52DLpTM';
       
       fuse.registerInAppPurchase(this.inAppPurchaseResponse, state, price, 
                 currency, product_id, transaction_id, token);
   }
 }
 
 function inAppPurchaseResponse(state:int, transaction_id:String):void
 {
   if (state == 1)
   {
       trace('In-App Purchase successfully validated! ' + state + ', tx_id = ' + transaction_id);
   }
   else if (state == -1)
   {
       trace('In-App Purchase no validated [no attempt made] ' + state + ', tx_id = ' + transaction_id);
   }
   else if (state == 0)
   {
       trace('In-App Purchase failed!' + state + ', tx_id = ' + transaction_id);
   }
   else
   {
       trace('In-App Purchase unknown state:' + state + ', tx_id = ' + transaction_id);
   }
 }