This Web SDK for App Launch on IBM Cloud services, provides a library for developers to build Web applications.
App Launch on IBM Cloud services enables the developers to build engaging apps by controlling reach and roll out of App features while measuring the defined metrics.
Ensure that you go through IBM Cloud App Launch service documentation before you start.
Master | Development |
---|---|
- Setup App Launch Service
- Installation
- Enabling Web applications to use IBM App Launch
- Feature Toggle
- Metrics
- InApp Messages
- Destroy
- Samples and videos
This section describes how to install and use the App Launch SDK for JavaScript client and to further develop your Web applications.
For installing the Javascript SDK in your web applications follow the steps -
-
Download the
icapplaunch.js
andicapplaunch-inapp.css
from here -
Include the IBM Cloud AppLaunch CSS File in your web application
<link rel="stylesheet" type="text/css" href="icapplaunch-inapp.css">
-
Include IBM Cloud AppLaunch Web SDK to the web application.
<script src="icapplaunch.js" async></script>
var config = new IBMAppLaunch.AppLaunchConfigBuilder().fetchPolicy(IBMAppLaunch.RefreshPolicy.REFRESH_ON_EVERY_START).cacheExpiration(30).eventFlushInterval(30).deviceID("deviceUUid").build();
The AppLaunchConfig builder is used to customize the following:
-
eventFlushInterval
: Sets/Decide the time interval on when the events should be sent to the server. The default value is 30 minutes. -
cacheExpiration
: Sets/Decide the time interval until when the actions should be valid for. The default value is 30 minutes.Note This parameter is effective only if the fetch policy is set to
IBMAppLaunch.RefreshPolicy.REFRESH_ON_EXPIRY
orIBMAppLaunch.RefreshPolicy.BACKGROUND_REFRESH
-
fetchPolicy
: This parameter decides on how frequently the actions should be fetched from the server. The values can be one of the following:-
IBMAppLaunch.RefreshPolicy.REFRESH_ON_EVERY_START
-
IBMAppLaunch.RefreshPolicy.REFRESH_ON_EXPIRY
-
IBMAppLaunch.RefreshPolicy.BACKGROUND_REFRESH
-
deviceId
: This parameter must be unique. If not specified, default deviceID generation mechanism is used by SDK.Note: Do not rely on the default implementation of the deviceID generation mechanism as it is not guarenteed to be unique.
var user = new IBMAppLaunch.AppLaunchUserBuilder().userID("vittal").attributes("email","vittalpai@xyz.com").build();
The AppLaunchUser builder is used to provide the following information:
-
userId
: The user to be registered -
custom
: This can be used to pass any optional custom user attributes.
IBMAppLaunch.initialize(IBMAppLaunch.ICRegion.US_SOUTH, "appGUID", "clientSecret", config, user).then(
function(success) {
// Intialization Success
}, function(failure) {
// Intialization Failure
});
Where region
parameter specifies the location where the app is hosted. You can use any of the following values:
IBMAppLaunch.ICRegion.US_SOUTH
IBMAppLaunch.ICRegion.UNITED_KINGDOM
IBMAppLaunch.ICRegion.SYDNEY
IBMAppLaunch.ICRegion.US_SOUTH_STAGING
IBMAppLaunch.ICRegion.UNITED_KINGDOM_STAGING
The appGUID
is the app launch app GUID value, while clientSecret
is the appLaunch client secret value which can be obtained from the service console.
-
Use the
IBMAppLaunch.isFeatureEnabled("feature-code");
to check if the feature is enabled for the app. -
Use the
IBMAppLaunch.getPropertyofFeature("feature-code","property-code")
to get the value of the particular property in a feature.
To send metrics to the server use the IBMAppLaunch.sendMetrics(["metric-code"]);
API. This API call sends the metrics information to the server.
To display InApp messages invoke the following API
IBMAppLaunch.displayInAppMessages();
This method unregisters the user from AppLaunch Service and clears the cache
IBMAppLaunch.destroy().then(
function(success){
//Success
}, function(failure) {
//Failure
});
- For samples, visit - Github Sample
- Visit the IBM Cloud Developers Community.
Twitter| YouTube | Blog | Facebook | Meetup
======================= Copyright 2016-17 IBM Corp.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.