Initial setup
Adding permissions
Batch Air Native Extension (ANE) is compatible with both iOS 6+ and Android 2.3+. It supports AIR 4.0+ and Flex SDK 4.12 or higher is required. You can download the latest version at the Apache Website.
Batch requires only one permission: Internet access, so you need to be sure you have it in your android manifest (in the app.xml xml available into the src directory of your app) otherwise Batch will not start correctly on Android.
<uses-permission android:name="android.permission.INTERNET" />
Your first start
Download the ANE and integrate it into your AIR app: Add ANE into your app.
You now are ready to implement the main functions of Batch into your app. The start function requires a configuration containing your API keys, so a typical implementation will be:
<?xml version="1.0" encoding="utf-8"?>
<s:ViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" firstView="views.FirstView"
applicationDPI="160">
<fx:Declarations>
</fx:Declarations>
<fx:Script>
<![CDATA[
import com.batch.ane.Batch;
import com.batch.ane.Config;
// Build config
var config:Config = new Config().setAndroidAPIKey("YOUR_ANDROID_API_KEY").setiOSAPIKey("YOUR_IOS_API_KEY");
// Call batch start with the config
Batch.start(config);
]]>
</fx:Script>
</s:ViewNavigatorApplication>
YOUR_API_KEY
is your Batch Dev or Live API key. You'll find the API keys needed to set up the SDK in ⚙ Settings → General:
- Dev API key: Use it for development or testing purposes. This API key won't trigger stats computation. Please take care not to ship an app on a Store with this API key.
- Live API key: Should be used in a production environment only and in the final version of your app on the Store.
Batch iOS API key must not be mistaken for the APNS environment Batch will output to the Xcode logs when starting. The environment depends on the app's provision, not on the Batch API Key used.
Batch ANE will automaticaly bind itself on the app lifecycle events (
Event.ACTIVATE
andEVENT.DEACTIVATE
), you do not need to implement it yourself.
Testing your integration
Congratulations on finishing the bulk of the integration!
If you want to validate your implementation before proceeding with the Push setup, you can locate the log that Batch posts in your app log in devmode.
- On Android, you can access the logcat through your preferred method, although using Android Studio's method is quite simple.
- On iOS, you will find it in the Xcode console after deploying a build to your device while linked to your Mac.
Here is how it should look after a correct integration:
Batch: Batch is running in dev mode (your API key is a dev one)
[Batch] Batch started with a DEV API key