Initial Setup

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.
  3. Click here to get the latest SDK available.

iOS

You can download the iOS SDK Here.

Importing

Import1.png

Import the Fuse SDK into your project, (Right Click YourProject > Add Files to "YourProject").


Import2.png

Next browse to the location where you have uncompressed the SDK and select FuseAPI, on the same dialog, choose "Create groups for any added folders". Now click "Add".

Import3.png

Once finished, your project should look like this.



Be sure that, if your project targets both iPhone and iPad, when you are adding the library that it is included in both targets.

Once this is complete you can add the following line of code in your application or pre-compiled header:

 #import "FuseAPI.h" 

Project Configuration

Required Frameworks

The Fuse SDK requires the following frameworks:

  1. GameKit.framework
  2. StoreKit.framework
  3. CoreTelephony.framework
  4. AdSupport.framework
  5. Foundation.framework
  6. UIKit.framework
  7. QuartzCore.framework
  8. CoreGraphics.framework
  9. EventKit.framework
  10. EventKitUI.framework
  11. MessageUI.framework
  12. CoreMedia.framework
  13. MediaPlayer.framework
  14. AVFoundation.framework
  15. SystemConfiguration.framework
  16. Twitter.framework
  17. Social.framework (weak link)
  18. CoreLocation.framework
  19. libsqlite3.dylib


Import4.png

In order to include an existing framework, navigate to the target with properties of your build. Select 'Build Phases', then expand 'Link Binary with Libraries' and press the '+' to add an item.

On the pop-up screen, select the frameworks to be added.

If you are targeting your application to support an early version of iOS, you will need to weak-link the CoreTelephony.framework (before iOS 4.0) and AdSupport.framework (below iOS 6.0) in your application in order for it to compile and work properly. Change "Required" to "Optional" in the "Link Binary with Library" section of the build target.


Linker Flags

Import5.png

You will also need to add the "-all_load" flag to your "Linker Flags" section . To accomplish this, view your target properties and choose 'Build Settings'. Select the "Build" tab and find the "Other Linker Flags" entry in the "Linking" section. Be sure that the "Configuration" drop down box is set to "All Configurations". Add "-all_load" to the settings. Once these steps have been completed you can begin feature integration.



Android

You can download the Android SDK Here.

Importing

The Fuse API contains these files:

 - Code/FuseSDK.jar
 - README.md

Once you have downloaded the files you need to import the files into your Eclipse Project File. First we need to add FuseSDK.jar as a library to the build path of the project, to do this in Eclipse:

1) Right Click the project/libs folder and select Import... from the dropdown menu

AndroidImport1.png

2) Select General > File System from the Import dialog box and press Next

AndroidImport2.png

3) Browse to the FuseSDK/Code folder

AndroidImport3.png

4) Check FuseSDK.jar and click on Finish

AndroidImport4.png

The .jar file should now be imported to your project.

Next we need to add it to the Build path libraries.

1) Right click on the project and select Build Path > Configure Build Path from the dropdown menu

AndroidImport5.png

2) In the dialog box that opens You are already in the Java Build Path page, click on the Libraries Tab

AndroidImport6.png

3) Click on the Add JARs... button and select the FuseSDK.jar file that you imported to your project and click ok.

AndroidImport7.png

4) The JAR file will be added to the library list. Press OK to close the dialog.

AndroidImport8.png

When this is complete you can import FuseAPI classes.

Set up

Project Configuration

Manifest

NoteBubble.png

The minimum supported target is API level 11

Fuse activities must be configured in the AndroidManifest.xml file. Add these activities under your application Tag.

   <uses-sdk
       android:minSdkVersion="11"
       android:targetSdkVersion="<11 or higher>" />

       <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>
      <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="com.acme.FuseAndroidGame.fusepowered.push.FuseRecordGCMResponse" />
               <category android:name="android.intent.category.DEFAULT" />
           </intent-filter>
       </activity>
       <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.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.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.vungle.sdk.VungleAdvert"
           android:configChanges="keyboardHidden|orientation|screenSize"
           android:theme="@android:style/Theme.NoTitleBar.Fullscreen" />
       <service android:name="com.vungle.sdk.VungleIntentService" />
       <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.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.adapters.LRActivity"
           android:configChanges="keyboardHidden|orientation|screenSize"
           android:theme="@android:style/Theme.Translucent.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"
           android:windowSoftInputMode="adjustResize" />
       <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" />

Other Configuration Changes

The following permissions are needed to be able to use the Fuse SDK. They should be added to the AndroidManifest.xml file if they are not already there.

   <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" />
   <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
   <uses-permission android:name="android.permission.GET_ACCOUNTS" />
   <uses-permission android:name="android.permission.WAKE_LOCK" />
   <permission android:name="<Application Package>.permission.C2D_MESSAGE" android:protectionLevel="signature" />

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

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

The following style must be added to "styles.xml" (directory: 'res' > 'values'):

 <xml version="1.0" encoding="utf-8"?>
 <resources>
 
   <!--Exiting styles-->
   ...
 
   <!--Add This-->
   <style name="Theme.transparent" parent="android:style/Theme.Translucent"> 
     <item name="android:windowNoTitle">true</item> 
     <item name="android:windowContentOverlay">@null</item> 
     <item name="android:backgroundDimEnabled">true</item> 
     <item name="android:background">@android:color/transparent</item> 
   </style>
 </resources>

You can see more information on styles Here.


NoteBubble.png

You must also add Google Play Services and the Android v4 support library to your project as an Android library project dependency. See Here for a guide on Google Play Services and Here for the support library.


Once this is complete, you will be able to compile your project with the Fuse SDK included.

Import Statements

Before we start making calls with the Fuseboxx™ SDK we need to import some tools first. The Fuse files to be imported are all in the com/fusepowered directory provided with the SDK. The import statements should look like this:

import com.fusepowered.fuseactivities.*;
import com.fusepowered.fuseapi.*;
import com.fusepowered.util.*;
import com.fusepowered.activities.*;

import android.content.Context;

You need to import android.content.Context so you can use AppContext when messaging the Fuse System.

Adobe Air

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 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.vungle.sdk.VungleAdvert"
           android:configChanges="keyboardHidden|orientation|screenSize"
           android:theme="@android:style/Theme.NoTitleBar.Fullscreen" />
       <service android:name="com.vungle.sdk.VungleIntentService" />
       <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.activities.L1LActivity" android:theme="@android:style/Theme.Translucent"
                 android:configChanges="orientation|keyboardHidden|screenSize"/>
       <activity android:name="com.fusepowered.l1.activities.L1DActivity" android:theme="@android:style/Theme.Translucent" />
       <activity android:name="com.fusepowered.l1.activities.L1EActivity" android:theme="@android:style/Theme.Translucent" />
       <activity android:name="com.fusepowered.l1.activities.L1VActivity" android:theme="@android:style/Theme.Translucent"
                 android:configChanges="orientation|keyboardHidden|screenSize" />
       <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.

Unity

Downloading the Fuse SDK

An open-source version of the Unity wrapper is available here. Any additions required to the wrapper can be made and compiled for your needs.

The Fuse Unity SDK will prompt you to update automatically when there is a new version available. You can change the auto update settings by selecting "FuseSDK > Preferences" from the menu bar..

Importing

Next you need to import the package into your Unity project.

Unity1.jpg ImportPackage.png

NoteBubble.png

You can also drag-and-drop the contents of the "Assets" folder from the wrapper directory to your Assets directory for your project

Set Up

First you should create the FuseSDK Prefab by selecting "FuseSDK > Regenerate Prefab" from the menu bar. The prefab will be generated as "Assets/FuseAPI/FuseSDK.prefab". The prefab will have the FuseAPI.cs script attached to it.


The first step is to add your API Keys to the "Android Game ID" and/or "iOS Game ID" fields of the Fuse API component.

Then you need to create a script to call the API functions (for this example we'll use a C# script).

Unity3.jpg

You should register the callbacks on the Awake() function to ensure that they are bound before the session starts;

 void Awake()
 {
     FuseAPI.SessionStartReceived += SessionStarted;
     FuseAPI.AdAvailabilityResponse += AdAvailabilityResponse;
     FuseAPI.AdWillClose += AdWillClose;
     FuseAPI.SessionLoginError += SessionLoginError;
 }


The fuse session is started automatically so you can start checking if an ad is available and display it if there is one right away;

 private void SessionStarted()
 {
     StartCoroutine(WaitAndCheckAd());
 }
 
 private IEnumerator WaitAndCheckAd()
 {
     yield return new WaitForSeconds(1);
     FuseAPI.CheckAdAvailable();
 }
 
 private void AdAvailabilityResponse(int IsAdAvailable, int HasError)
 {
     if (IsAdAvailable == 1)
     {
         FuseAPI.ShowAd();
     }
     else
     {
         StartCoroutine(WaitAndCheckAd());
     }
 }

In this example, we are implementing a function to check for ads periodically every second until one is found.

The "SessionStarted" callback is executed when the session has started, which executes the WaitAndCheckAd() function as a coroutine to wait for one second and check for an ad.

The "AdAvailabilityResponse" callback is executed after calling FuseAPI.CheckAdAvailable() and will tell you if an ad is available or if there's an error. This example shows using the returned value of "1" (meaning an ad is available) to trigger showing the ad, and starting the WaitAndCheckAd() coroutine in any other case.


The reason behind implementing the ad display algorithm in this way is because the ad waterfall may take some time to be retrieved from the server. Checking for ads immediately when the session has started will usually result in no ad being available to display.

You can pick up the closing of an ad with the AdWillClose callback or a session login error with the "SessionLoginError" callback and execute further code if you choose to.

 private void AdWillClose()
 {
     //AdWillClose
 }
 
 private void SessionLoginError(int obj)
 {
     //SessionLoginError
 }

Finally we need to complete the script by unregistering actions on onDestroy():

 void onDestroy()
 {
     FuseAPI.SessionStartReceived -= SessionStarted;
     FuseAPI.AdAvailabilityResponse -= AdAvailabilityResponse;
     FuseAPI.AdWillClose -= AdWillClose;
     FuseAPI.SessionLoginError -= SessionLoginError;
 }

NoteBubble.png

You can view a complete example script with Registering and Unregistering Callbacks Here.

Next, make sure that the C# script is attached as component within your scene.

Unity7.jpg

To test on a device, you'll first need to update the Bundle Identifier to match your profile (in Unity: Edit->Project Settings->Player)

Unity8.jpg

Next drag the FuseAPI prefab to the hierarchy.

Unity10.png Unity9.png

NoteBubble.png

For both iOS and Android platforms, the Fuse Unity wrapper will automatically collect push notifications tokens.

Marmalade

You can download our Marmalade wrapper on our Github Repository. This package contains everything you'll need to integrate FuseBoxx™ in to your Marmalade based applications. For a detailed explanation of all the FuseAPI function calls, see FuseAPI/docs/FuseAPI.txt within the downloaded directory (or click here for a direct link).

Set Up

Once you've downloaded the FuseAPI Marmalade wrapper, you must include the FuseAPI in your marmalade project.

  1. Copy the FuseAPI directory into your extensions folder.
  2. Subproject the FuseAPI Extension in your Marmalade Project's MKB File:
subprojects
{
     FuseAPI
}

NoteBubble.png

For an example of what your .mkb file should look like Click Here

To use the FuseAPI extension in your project, first include the FuseAPI header:

 #include "FuseAPI.h"

Next call the StartSession method. For more info, see How to set up your StartSession method.

Register Callbacks

Before you start a session you should register Fuse callbacks. Doing so will allow the FuseAPI to send messages to your game.

For detailed explanations of all callbacks, see FuseAPI/docs/Callbacks.txt. Or Click Here for a direct link.

Registering callbacks should look like this:

FuseAPIRegister(FUSEAPI_SESSION_STARTED, &GotSessionReceived, NULL);
FuseAPIRegister(FUSEAPI_SESSION_LOGIN_ERROR, &SessionLoginError, NULL);

Your callback handling functions, as defined in your code, should look like this:

int32 GotSessionReceived(void* systemData, void* userData)
{
      //Handle callback here
      return 1;
}

All of these are in the format of FuseAPIRegister(Fuse Function, &CallbackHandlerName, Variable)

&CallbackHandlerName refers to whatever function will be called once a callback has been received. In the above example, after starting your session, a function named GotSessionReceived will be called.

Unregistering Callbacks

When the game is terminated, you must unregister that callback function you have created, which should look like this:

FuseAPIUnRegister(FUSEAPI_SESSION_STARTED, &GotSessionReceived);
FuseAPIUnRegister(FUSEAPI_SESSION_LOGIN_ERROR, &SessionLoginError);

The FuseAPIUnRegister function should have the callback id and the reference to the callback handling function as parameters.

NoteBubble.png

For an example of what your .cpp file should look like with registering and unregistering Callbacks Click Here