| copyright |
|
||
|---|---|---|---|
| lastupdated | 2017-01-14 |
{:new_window: target="_blank"} {:shortdesc: .shortdesc} {:screen:.screen} {:codeblock:.codeblock}
{: #mobileanalytics_sdk}
The {{site.data.keyword.mobileanalytics_short}} Client SDKs are currently available for Android, iOS, WatchOS, Cordova and Web. {: shortdesc}
{: #install-sdk-android}
The {{site.data.keyword.mobileanalytics_short}} Client SDK is distributed with Gradle, a dependency manager for Android projects. Gradle automatically downloads artifacts from repositories and makes them available to your Android application.
-
Create an Android Studio
{: new_window} project or open an existing project.
-
Open the
build.gradlefile that is in your app module.
Tip: Your Android project might have two build.gradle files: one for the project and one for the app module. Make sure to use the app module file.
-
Find the
Dependenciessection of thebuild.gradlefile and add a compile dependency for the {{site.data.keyword.mobileanalytics_short}} Client SDK. Your repositories statement should be similar to the following code example:dependencies { compile 'com.ibm.mobilefirstplatform.clientsdk.android:analytics:1.+' // other dependencies }{: codeblock}
-
Synchronize your project with Gradle by clicking Tools > Android > Sync Project with Gradle Files.
-
Open the
AndroidManifest.xmlfile for your Android project. You can find this file in app > manifests. Add internet access permission under the<manifest>element:<uses-permission android:name="android.permission.INTERNET" />{: codeblock}
-
You have now installed the Android Client SDK. Next, import and initialize the Analytics Client SDK.
{: #installing-sdk-ios}
The {{site.data.keyword.mobileanalytics_full}} SDK enables you to instrument your mobile application. The Swift SDK is available for iOS and watchOS.
{: #before-you-begin-ios notoc}
Make sure that you correctly set up Xcode. To learn how to set up your iOS development environment, see the Apple Developer website {: new_window}. Read about the Xcode requirements
{: new_window} for Client SDK Swift Analytics.
The {{site.data.keyword.mobileanalytics_short}} SDK is distributed with CocoaPods {: new_window} and Carthage
{: new_window}, which are dependency managers for Cocoa projects. CocoaPods and Carthage automatically download artifacts from repositories and makes them available to your application. Select CocoaPods or Carthage:
{: #cocoapods notoc}
-
Follow the {{site.data.keyword.Bluemix_notm}} Mobile Services Swift SDK instructions
{: new_window} on GitHub to install
BMSAnalyticsusing Cocoapods and add it to your Podfile. -
After you have installed the iOS Client SDK, import and initialize the Analytics Client SDK.
{: #carthage notoc}
If you are not using using CocoaPods, you can add frameworks to your project using Carthage {: new_window}.
-
Follow the Carthage installation instructions
{: new_window} on GitHub to install
BMSAnalytics. -
After you have installed the iOS Client SDK, import and initialize the Analytics Client SDK.
{: #installing-sdk-cordova}
The {{site.data.keyword.mobileanalytics_full}} Cordova plugin enables you to instrument your mobile application.
-
Create a Cordova
{: new_window} project or open an existing project.
-
Add Android and iOS platforms to your Cordova application. Run one or both of the following commands from the command line. Currently, Cordova-CLI V6.3.0 or earlier is supported:
Android:
cordova platform add android@5.2.2{: codeblock}
iOS:
cordova platform add ios{: codeblock}
-
If you added the Android platform, you must add the minimum supported API level to the
config.xmlfile of your Cordova application. Open theconfig.xmlfile and add the following line to the<platform name="android">element:<platform name="android"> <preference name="android-minSdkVersion" value="15"/> <preference name="android-targetSdkVersion" value="23"/> <!-- add minimum and target Android API level declaration --> </platform>{: codeblock}
The minSdkVersion value must be version 15 or higher. Refer to the Android Platform Guide {: new_window} to stay current with the supported targetSdkVersion for the Android SDK.
-
If you added the iOS operating system, update the
<platform name="ios">element with a target declaration:<platform name="ios"> <preference name="deployment-target" value="8.0"/> <!-- add deployment target declaration --> </platform>{: codeblock}
-
Add the
bms-coreplugin.cordova plugin add bms-core{: codeblock}
-
Verify that the plugin installed successfully by running the following command:
cordova plugin list{: codeblock}
-
Configure your Android and iOS environment
{: new_window}.
-
You have now installed the Cordova plugin and configured your environments. Next, import and initialize the Analytics Client SDK.
{: #web-sdk-cordova}
The {{site.data.keyword.mobileanalytics_full}} SDK enables you to instrument your web application.
-
Make sure that you have a web server and a browser setup (eg. Chrome, Firefox) .
-
Create a new web app or use a existing one and put this WebSDK within you project to be accessed by the app code .
-
Add the web plugin by either adding this script in the
index.htmlfile of web app:```Html <script src="bms-clientsdk-web-analytics/bmsanalytics.js"></script> ``` {: codeblock} Or by using module loader requirejs. The name used as reference API is same as the argument name (`BMSAnalytics`) used. ```Javascript require.config({ 'paths': { 'bmsanalytics': 'bms-clientsdk-web-analytics/bmsanalytics' } }); ``` {: codeblock}
{: #rellinks notoc}
{: #sdk notoc}
- Android SDK
{: new_window}
- iOS SDK
{: new_window}
- Cordova Plugin Core SDK
{: new_window}
- Web SDK
{: new_window}
{: #api notoc}
- REST API
{:new_window}