copyright | lastupdated | ||
---|---|---|---|
|
2019-02-19 |
{:new_window: target="_blank"} {:shortdesc: .shortdesc} {:screen:.screen} {:codeblock:.codeblock}
{: #prerequisites}
{: #prerequisites_1}
- In the IBM Cloud Catalog, click Mobile > Mobile Analytics.
- Provide a Service name.
- Click Create.
- Choose to connect to other existing apps, or leave it unbound.
You can choose to create either a bound service or an unbound service. Bound services are connected to other IBM Cloud apps, while unbound services are standalone and not connected to other apps.
{: #prerequisites_app}
Import and install the {{site.data.keyword.mobileanalytics_short}} Client SDKs. You can optionally use the {{site.data.keyword.mobileanalytics_short}} REST API {:new_window}.
###Import the Client SDKs
Import the Client SDKs and initialize them with the following code snippet to record usage analytics:
-
Android
Add the following
import
statements to the beginning of your project file:import com.ibm.mobilefirstplatform.clientsdk.android.core.api.*; import com.ibm.mobilefirstplatform.clientsdk.android.analytics.api.*; import com.ibm.mobilefirstplatform.clientsdk.android.logger.api.*;
{: codeblock}
-
iOS
The Swift SDK is available for iOS and watchOS.
Import the
BMSCore
andBMSAnalytics
frameworks by adding the followingimport
statements to the beginning of yourAppDelegate.swift
project file:import BMSCore import BMSAnalytics
{: codeblock}
-
Cordova
Add the Cordova plugin by running the following command from your Cordova application root directory:
cordova plugin add bms-core
{: codeblock}
-
Web
Add the web plugin by either adding this script in the
index.html
file of web app:<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.require.config({ 'paths': { 'bmsanalytics': 'bms-clientsdk-web-analytics/bmsanalytics' } }); require(['bmsanalytics'], function(BMSAnalytics) { BMSAnalytics.send(); }
{: codeblock}
Your next step is to Instrument your app .