Jump to: navigation, search

Adobe AIR

Revision as of 19:44, 6 December 2016 by Akokulu (Talk | contribs) (Android)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Adobe AIR Integration

NoteBubble.png

Important: Please test your integration on a device. Fuse 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 Adobe AIR wrapper Here.

Importing

The Fuse Adobe AIR Wrapper contains the following files:

  - AirFuseSDK.ane
  - AirFuseSDK.swc
  
  - AirFuseAdapterAdColony.ane
  - AirFuseAdapterAdColony.swc
  
  - AirFuseAdapterAppLovin.ane
  - AirFuseAdapterAppLovin.swc
  
  - AirFuseAdapterHyprMX.ane
  - AirFuseAdapterHyprMX.swc

Adobe Flash Builder

1. Download the Fuse Adobe AIR SDK

2. In your Flash Builder project, import the AirFuseSDK.ane and AirFuseSDK.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 AirFuseSDK.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 AirFuseSDK.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.

Adobe Flash CC

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

Copy the AirFuseSDK.ane and AirFuseSDK.swc files into your project.

Installation 1.png


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

Installation 2.png


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

Installation 3.png

Set up

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-permission android:name="android.permission.INTERNET"/>
            <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
            <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
            <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
            <uses-permission android:name="android.permission.GET_ACCOUNTS" />

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.

       <uses-sdk android:minSdkVersion="11" android:targetSdkVersion="19" />
       <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|screenSize" />
        <activity
            android:name="com.fusepowered.m2.mobileads.M2RActivity"
            android:configChanges="keyboardHidden|orientation|screenSize" />
        <activity
            android:name="com.fusepowered.m2.common.M2Browser"
            android:configChanges="keyboardHidden|orientation|screenSize" />
        <activity
            android:name="com.fusepowered.m2.mobileads.M2RvpActivity"
            android:configChanges="keyboardHidden|orientation|screenSize" />

        <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.ads.adapters.FuseInterstitialActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:noHistory="true"
            android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />

        <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.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.adapters.MRaidActivity"
            android:hardwareAccelerated="true"
            android:configChanges="orientation|keyboard|keyboardHidden|screenLayout|screenSize"
            android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"
            android:windowSoftInputMode="adjustResize" />
        <activity
            android:name="com.fusepowered.ads.adapters.MRaidVideoActivity"
            android:hardwareAccelerated="true"
            android:configChanges="orientation|keyboard|keyboardHidden|screenLayout|screenSize"
            android:theme="@android:style/Theme.Black.NoTitleBar"
            android:windowSoftInputMode="adjustResize" />

        <activity
            android:name="com.fusepowered.as.view.ASVastInterstitialActivity"
            android:theme="@android:style/Theme.Translucent"
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
        <activity
            android:name="com.fusepowered.as.view.ASWebviewInterstitialActivity"
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
        <activity android:name="com.fusepowered.as.view.ASVpaidInterstitalActivity"
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />


        <activity
            android:name="com.fusepowered.al.adview.ALInterstitialActivity" />
        <activity
            android:name="com.fusepowered.al.adview.ALConfirmationActivity" />

        <activity
            android:name="com.fusepowered.ads.adapters.ALActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />

        <activity android:name="com.fusepowered.im.rendering.InMobiAdActivity"
            android:configChanges="keyboardHidden|orientation|keyboard|smallestScreenSize|screenSize"
            android:theme="@android:style/Theme.Translucent.NoTitleBar"
            android:hardwareAccelerated="true" />

        <activity
            android:name="com.google.android.gms.ads.AdActivity"
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
            android:theme="@android:style/Theme.Translucent" />

        <activity
            android:name="com.fusepowered.vast.activity.VASTActivity"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
            android:screenOrientation="sensorLandscape" />

        <activity
            android:name="com.fusepowered.nx.monetization.activities.InterstitialActivity"
            android:configChanges="orientation|screenSize"
            android:hardwareAccelerated="true"
            android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
        <activity
            android:name="com.fusepowered.nx.videoplayer.VideoActivity"
            android:configChanges="orientation|screenSize" />

        <activity
            android:name="com.apptracker.android.module.AppModuleActivity"
            android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
            android:hardwareAccelerated="false" />

        <activity
            android:name="com.facebook.ads.InterstitialAdActivity"
            android:configChanges="keyboardHidden|orientation|screenSize" />

        <activity
            android:name="com.vungle.publisher.FullScreenAdActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen"/>
        <activity
            android:name="com.fusepowered.fuseactivities.FuseApiMoregamesBrowser"
            android:label="FuseApiMoregamesBrowser">
            <intent-filter>
                <action android:name="com.fusepowered.fuseactivities.FuseApiMoregamesBrowser" />
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

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 corresponding files from our SDK to your project and add the following lines to your application xml file in the extensions section:

  <extensionID>com.fuse.AirFuseAdapterAdColony</extensionID>
  <extensionID>com.fuse.AirFuseAdapterHyprMX</extensionID>
  <extensionID>com.fuse.AirFuseAdapterAppLovin</extensionID>

Using The SDK

Import Statements

Before we start making calls with the Fuse SDK we need to import some tools first. The import statements should look like this:

  import com.fuse.ane.AirFuseSDK;
  import com.fuse.ane.AirFuseSDKEvent;

Initializing Fuse SDK

First, you need to create an instance of the AirFuseSDK object and initialize it

  private var fuse:AirFuseSDK;
  fuse = AirFuseSDK.getInstance();

Setting Up the Event Listener

To handle event callbacks, you need to implement the event delegate method to cover for every callback you will require. Sample usage for each case will be covered in the following sections.

  public function onStatus( event : StatusEvent ) : void
  {
  	switch(event.code)
  	{
  		case AirFuseSDKEvent.SESSION_START:
  			break;
  		case AirFuseSDKEvent.SESSION_START_ERROR:
  			break;
  
  		case AirFuseSDKEvent.AD_AVAILABILITY_AVAILABLE:
  			break;
  		case AirFuseSDKEvent.AD_AVAILABILITY_NOT_AVAILABLE:
  			break;
  		case AirFuseSDKEvent.AD_AVAILABILITY_ERROR:
  			break;
  
  		case AirFuseSDKEvent.DID_CLOSE_INTERSTITIAL:
  			break;
  		case AirFuseSDKEvent.REWARDED_AD_COMPLETE:
  			break;
  
  		case AirFuseSDKEvent.IAP_OFFER_ACCEPTED:
  			break;
  		case AirFuseSDKEvent.VIRTUAL_GOODS_OFFER_ACCEPTED:
  			break;
  
  		case AirFuseSDKEvent.INAPP_PURCHASE_RESPONSE:
  			break;
  
  		case AirFuseSDKEvent.GCM_TOKEN_RECEIVED:
  			break;
  	}
  }

After creating the listener method, you need to add it to your fuse object

  fuse.addListener(StatusEvent.STATUS, onStatus);

Starting a Session

Before making any other calls on the Fuse SDK, you need to register the start of a session using the startSession 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.

  fuse.startSession('<YOUR APP ID>');

When this call is made, the listener method will be called with the following event parameters

  public function onStatus( event : StatusEvent ) : void
  {
  	switch(event.code)
  	{
  		case AirFuseSDKEvent.SESSION_START:
  			log('Session start received');
  			break;
  		case AirFuseSDKEvent.SESSION_START_ERROR:
  			log('Session start failed with code: ' + event.level);
  			break;
  	}
  }

The error code stored in event.level denotes the reason the session failed to start. The error codes and their meanings are as follows;

  • 0: No error has occurred
  • 1: The user is not connected to the internet
  • 2: There was an error in establishing a connection with the server.
  • 3: Data was received, but there was a problem parsing the xml.
  • 4: The server has indicated the data it received was not valid.
  • 5: The session has recieved an error and the operation did not complete due to this error.
  • 6: The request was not valid, and no action will be performed.
  • 7: Unknown error.

Showing Ads

NoteBubble.png

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

Caching Ads

You can use the following function call to fetch an ad, offer, or rewarded video from the given zone and prepare it to be shown;

    fuse.preloadAdForZoneID('ZONE ID');

When this call is made, the listener method will be called with the following event parameters

  public function onStatus( event : StatusEvent ) : void
  {
  	switch(event.code)
  	{
  		case AirFuseSDKEvent.AD_AVAILABILITY_AVAILABLE:   
  			log('An ad is available to be displayed');
  			break;
  		case AirFuseSDKEvent.AD_AVAILABILITY_NOT_AVAILABLE:
  			log('An ad is NOT available to be displayed!');
  			break;
  		case AirFuseSDKEvent.AD_AVAILABILITY_ERROR:
  			log('Caching an ad failed with the following code: ' + event.level);
  			break;
  	}
  }

This method is optional and is used to help ensure that an ad is shown in a timely manner. If the zone is not ready to display an ad, this will start loading an appropriate ad but will not show it until showAdForZoneID is called. If an ad is ready to be displayed, it does nothing. The listener method is always called after this function. Downloading an ad could take several seconds, depending on the size of the ad and connection speed. For best results, you should allow ample time for the ad to finish loading before attempting to show it. For example, when a game has a level completed screen and wants to show an ad when the user chooses to start the next level, you should call preloadAdForZoneID as soon as the level is completed and showAdForZoneID when the next level button is pressed.

The error code stored in event.level denotes the reason the session failed to start. The error codes and their meanings are as follows;

  • 0: No error has occurred
  • 1: The user is not connected to the internet
  • 2: There was an error in establishing a connection with the server.
  • 3: Data was received, but there was a problem parsing the xml.
  • 4: The server has indicated the data it received was not valid.
  • 5: The session has recieved an error and the operation did not complete due to this error.
  • 6: The request was not valid, and no action will be performed.
  • 7: Unknown error.

You can only cache one zone at a time; if you call this method for more than one zone, the latter calls will overwrite the formerly cached zone.

Display Ads

Use the following method for displaying ads;

        //Simple usage. Show the next item in the zone; 
        fuse.showAdForZoneID(_zone_id);

This function attempts to display an ad if one is available. If no ad is immediately ready to display, this function waits up to 3 seconds for an ad to load and displays immediately if loading finishes. AdWillClose callback is always fired at some point after calling this method, either when the ad is closed, or when no ads are loaded before timing out.

When this call is made, the listener method will be called with the following event parameter

  public function onStatus( event : StatusEvent ) : void
  {
  	switch(event.code)
  	{
  		case AirFuseSDKEvent.DID_CLOSE_INTERSTITIAL:
  			log('The Ad Has Been Closed');
  			break;
  	}
  }

This method is is always fired at some point after calling showAdForZoneID, either when the ad is closed, or when no ads are loaded before timing out.

Rewarded Ads

You can check whether a zone includes rewarded content or not by calling the zoneHasRewarded method;

        fuse.zoneHasRewarded('ZONE ID'); //returns boolean

You can get the information on the reward by calling the getRewardedInfoForZoneID method;

        fuse.getRewardedInfoForZoneID('ZONE ID'); //returns RewardedInfo

If the showAdForZoneID call attempts to display a rewarded ad, by default, an alert will be shown offering the reward to the user, as well as one after the video confirming that they earned the reward. The alerts can be disabled by using the options parameter as shown below;

        //Show an ad, disabling the pre roll alert. 
        fuse.showAdForZoneID(_zone_id, false);
  
        //Show an ad, disabling the pre roll and post roll alerts. 
        fuse.showAdForZoneID(_zone_id, false, false);
  

Similarly, the button text on the alerts can be set as shown below;

        //Show an ad, using custom button text.
        fuse.showAdForZoneID(_zone_id,true,true,'Yes Please!','No Way!','SWEET!'); 

When this call is made, the listener method will be called with the following event parameter

  public function onStatus( event : StatusEvent ) : void
  {
  	switch(event.code)
  	{
  		case AirFuseSDKEvent.DID_CLOSE_INTERSTITIAL:
  			log('The Ad Has Been Closed');
  			break;
  		case AirFuseSDKEvent.REWARDED_AD_COMPLETE:
  			log('The Rewarded AdHas been watched to completion');
  			var rewardedInfo:RewardedInfo = RewardedInfo.DeserializeReward(event.level);
  			break;
  	}
  }

RewardedInfo: The RewardedInfo object contains the following;

  • preRollMessage (string): The message displayed when the reward is offered (before the rewarded video starts playing)
  • rewardMessage (string): The message displayed when the reward is granted (when the rewarded video is completed)
  • rewardItem (string): Rewarded Virtual Currency Type
  • rewardAmount (int): Rewarded Virtual Currency Amount

Offers

You can check whether a zone includes IAP or Virtual Goods offers by calling the zoneHasIAPOffer method and the zoneHasVirtualGoodsOffer method respectively

        fuse.zoneHasIAPOffer('ZONE ID'); //returns boolean
        fuse.zoneHasVirtualGoodsOffer('ZONE ID'); //returns boolean

If you are displaying ads with an IAP or Virtual Good offer and the user has accepted an offer, the listener method will be called with the following event parameters

  public function onStatus( event : StatusEvent ) : void
  {
  	switch(event.code)
  	{
  		case AirFuseSDKEvent.IAP_OFFER_ACCEPTED:
  			log('IAP Offer has been accepted');
  			var iapOfferInfo : IapOfferInfo = IapOfferInfo.DeserializeOffer(event.level);
  			break;
  		case AirFuseSDKEvent.VIRTUAL_GOODS_OFFER_ACCEPTED:
  			log('The Virtual Good Offer has been accepted');
  			var vgOfferInfo : VGOfferInfo = VGOfferInfo.DeserializeOffer(event.level);
  			break;
  	}
  }

IapOfferInfo: The IapOfferInfo object contains the following;

  • productId (string): ID of the offered item
  • productPrice (float): Price of the IAP (0 or the value in local currency if available eg. 2.99)
  • itemName (string): Name of the offered item
  • itemAmount (int): Quantity of items shown on the offer

VGOfferInfo: The VGOfferInfo object contains the following;

  • purchaseCurrency (string): The currency shown on the offer
  • purchasePrice (float): The price shown on the offer
  • itemName (string): Name of the offered item
  • itemAmount (int): Quantity of items shown on the offer

Tracking In App Purchases

NoteBubble.png

Before your app goes live you must set up Google In-App Purchase Validation through FusePowered Dashboard (see below)

NoteBubble.png

When registering in-app purchases, especially when testing IAP offers, make sure to use a US based iTunes account. Our system uses USD prices by default.

IAP Event Listener

Fuse allows tracking of in-app purchases in real-time. To track in app purchases, you first need to implement the listener function

  private function inAppPurchaseResponse(state:int, transaction_id:String):void
  {
      if (state == 1)
      {
          log('In-App Purchase successfully validated! - TID: ' + transaction_id);
      }
      else if (state == -1)
      {
          log('In-App Purchase could not be validated! - TID: ' + transaction_id);
      }
      else if (state == 0)
      {
          log('In-App Purchase failed! - TID: ' + transaction_id);
      }
      else
      {
          log('In-App Purchase Unknown State (' + state + ') - TID: ' + transaction_id);
      }
  }

Registering IAPs

To register the price and currency that a user is using to make in-app purchases, use the following call;

    fuse.registerInAppPurchase(inAppPurchaseResponse, state, price, currency, product_id, transaction_id, receiptOrToken);

Tracking Player Events

Player Level

To register a player's level, use the following function call where appropriate:

  FuseSDK.registerLevel(int playerLevel);

Currency Balances

The Fuse Event Tracking system can also track 4 different currency balances. To register one of these balances, use the following function call:

  FuseSDK.registerCurrency(int currencyIndex,int currencyBalance);

Following registerCurrency should be a number between 1 and 4 corresponding to the currency being tracked.

Birthday

To register a player's birthday, use the following function call where appropriate:

  FuseSDK.registerBirthday(int year, int month, int day);

Age

To register a player's age, use the following function call where appropriate:

  FuseSDK.registerAge(int age);

Gender

To register a player's gender, use the following function call where appropriate:

  FuseSDK.registerGender(int genderIndex);

0 = None

1 = Male

2 = Female

3 = Undecided

4 = Withheld

Parental Consent

To register a player's parental consent status, use the following function call where appropriate:

  FuseSDK.registerParentalConsent(bool consent);

Custom Player Events

Custom Player Events are used to track unique information on a per-player basis. Event numbers 1-10 are reserved for integers. To register Custom Player Events with integers, use the following function call where appropriate:

  FuseSDK.registerCustomEvent(int eventID,int eventValue);

Some examples of things you should track as integers:

  • Scores
  • Play Counts
  • Number of Friends

Some examples of things you should not track as integers:

  • Preexisting Metrics
  • Device or Player IDs
  • Account Info

Event numbers 11-20 are reserved for strings. To register Custom Player Events with strings, use the following function call where appropriate:

  FuseSDK.registerCustomEvent(int eventID,string eventValue);

Some examples of things you should track as strings:

  • Colours
  • Power Ups
  • Weapons

Some examples of things you should not track as strings:

  • Preexisting Metrics
  • Device or Player IDs
  • Dynamic Variables
  • Emails
  • Account Info

Push Notifications

iOS

On iOS, FuseSDK registers for push notifications automatically on startSession, if the app's provisioning profile supports push notifications.

Android

NoteBubble.png

Please refer to this page to set up GCM before enabling Fuse SDK Push notification features for Android devices.

To enable push notifications for Android, you need to make sure that the following is included in your manifest entries;

             <!-- Keeps the processor from sleeping when a message is received. -->
             <uses-permission android:name="android.permission.WAKE_LOCK" />
             <permission android:name="air.com.fusepowered.airsample.permission.C2D_MESSAGE" android:protectionLevel="signature" />
             <uses-permission android:name="com.acme.permission.C2D_MESSAGE" />
             <!-- App receives GCM messages. -->
             <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />

            <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="#YOUR APPLICATION PACKAGE#" />
                 </intent-filter>
               </receiver>
              <service android:name="com.fusepowered.push.FuseIntentService" />
           <activity 
               android:name="com.fusepowered.push.FuseRecordGCMResponse"
               android:configChanges="keyboardHidden|orientation"
               android:label="FuseRecordGCMResponse">
               <intent-filter>
                   <action android:name="#YOUR APPLICATION PACKAGE#.#YOUR APP NAME#.fusepowered.push.FuseRecordGCMResponse" />
                   <category android:name="android.intent.category.DEFAULT" />
               </intent-filter>
           </activity>

After starting a session, you need to make the following call to register for push notifications;

  fuse.registerForPushNotifications('GCM Project ID', 'GCM Alternate ID');

The first argument of this call is the GCM Project ID you entered on the Fuse Powered Dashboard. The second argument can be entered if you would like to use a secondary push notification library, and it can be left null otherwise.