Adobe Air

From Fuseboxx Wiki
Jump to: navigation, search

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.

  1. While AdRally is available to anyone, use of FuseBoxx™ requires an active partnership with Fuse Powered. Contact partners@fusepowered.com for all partnership inquiries.
  2. Sign in to FuseBoxx™ using your account credentials.

You can download the Air Native Extension for FuseAPI Here.


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

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.ACCESS_COARSE_LOCATION" />
      <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

NoteBubble.png

The ACCESS_COARSE_LOCATION permission is optional

Fuse activities must be configured in the AndroidManifest.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 FuseBoxx™. It can be found in the configuration tab in a specific game, or the (Admin>Integrate SDK>Your API Keys) section of FuseBoxx™. The API key is a 36-digit unique ID.


Showing Ads

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.

Push Notifications

Overview

Push Notifications are handled by FuseBoxx™. Simply set up your accounts with Google or Apple and you can control them all from within FuseBoxx™.

Google Cloud Messaging

Apple Push Notification Services

Configure

A small amount of information is required by FuseBoxx™ to begin sending push notifications.

To set up your accounts with FuseBoxx™, Click here.

Android: You will need your app specific Google Cloud Messaging Key

iOS: You will need app specific Production and Development Push Certificates


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);
   }
 }

Using App Parameters

App Parameters are one of the most powerful tools FuseBoxx™ offers, it allows you to change the value of certain variables in your application without the need for iterative and time consuming updates. The App Parameters for your app are stored on FuseBoxx™ servers and can be updated at any time using FuseBoxx™. You can use the App Parameters you set to create Custom App Experiences, for more information on Custom Experiences Click Here

To start using App Parameters, go to the App Parameters Page (Toolboxx Tab > App Config > App Parameters). You can add a parameter by pressing the Add Parameter button at the button of the list. Once you have created a new parameter simply click the Key or the Value to select and input your data. Make sure all App Parameters you intend to use are Enabled. NewParameters.png

After the parameters have been set it's time to implement them into your code. To retrieve the data from the FuseBoxx™ servers you need to pass the specific Key into the following call:

 var _key:String = "your_key";
 
 var _value:String = fuse.getGameConfigurationValue(_key);


Values are updated in the client each time a session is started from the Springboard or system tray.

Now that you have the Parameters in code, you can assign them how you want.


NoteBubble.png

It is a good idea to both check the variables against nil to see if they are working as expected, as well as Initialize all the variables in your code in case the user has never connected to the internet.