Welcome to Kony MobileFabric Tutorial

Using Kony MobileFabric, you can build apps for iOS, Android, PhoneGap, JavaScript, and Kony JavaScript.

About this Video:

In this tutorial we show you step by step how to set up a trial Kony MobileFabric account, how to configure Kony mobile services such as identity, integration, messaging, and sync, how to add backend services to your application, and how to invoke backend services by using Kony MobileFabric SDKs.

Kony MobileFabric How To

The following sections explain the steps to setup Kony MobileFabric, configure Salesforce account, configure Kony MobileFabric for your application. From start to finish, we walk you through each step, showing screen shots and giving detailed instructions to get you up and running quickly.

Overview

Kony MobileFabric is a Mobile Backend as a Service (MBaaS) provider that helps the developers build native and web apps for mobile. Various backend service are easily integrated with the application irrespective of whether the application is build by using iOS, Android, PhoneGap or JavaScript frameworks.

In this tutorial, you are going to create a CRM Salesforce application for iOS, Android, PhoneGap, and Kony Studio that authenticates the user against a Salesforce backend to retrieve Leads, Contacts and Accounts by using Kony MobileFabric.

Setting up MobileFabric Trial

To setup Kony MobileFabric , you need a Kony cloud account and atleast one development environment associated with your Kony account. If you do not have Kony Cloud account, please register as new user at http://www.kony.com /products/mbaas/trial and add your first development cloud.

If you already have Kony account, select existing user, provide your credentials and proceed.

Configuring Salesforce Account

You need Client ID and Client Secret from Salesforce to authenticate Kony MobileFabric application against Salesforce.

If you do not have an account already with Salesforce, sign up for free developer account trial.

Creating Connected Application

Once you log in to Salesforce, you need to create a connected application . Connected applications use OAuth2.0 protocol and provides tokens to access Salesforce APIs.

Once you create a con nected application , and define the Oauth scopes, Salesforce in return provides with Consumer Key and Consumer Secret for authorizing the connected application. Make a note of Consumer key and consumer secret. You will be using these tokens when configuring Kony MobileFabric. These are referred as ClientID and ClientSecret in Kony MobileFabric Portal.

The following are the necessary inputs required for creating connected application as shown below:

Note: On successful user login, Salesforce calls your callbackURL with an authorization code. For working with Kony MobileFabric, Salesforce callback has no much significance and could be anything.
In the sample CRM app, callback URL is provided as http://localhost:8080

Generating Security Token

A security token is an automatically generated key that you must add to the end of your password to log in to Salesforce from an untrusted network.

To generate a security token, follow these steps:

  1. Log in to your Salesforce developer account.
  2. Navigate to User Menu > My Settings.
  3. Under the My Settings left pane, click Personal >Reset My Security Token.
  1. Click the Reset Security Token button. The security token is sent to your registered email address.
  1. Append this security token to the Salesforce password (password+security token) when accessing Salesforce from Kony MobileFabric. Note: The security token is not required to be appended to Salesforce password in production instance of KonyCloud because the KonyCloud IP addresses would be whitelisted in Salesforce.

Configuring Kony Mobi leFabric

Now that you have activated Kony MobileFabric cloud and set up Salesforce account configuration, you need to configure Kony MobileFabric.

Creating MobileFabric Application

To create MobileFabric app, follow these steps:

  1. Log in to your Kony Cloud portal.
  2. Click Apps in the left menu.
  3. Under the Applications tab in the Manage Apps page, click Add New App to add new applications.
    A new Kony MobileFabric application is created and you are navigated to the app configuration page.
  4. To change the app name, click the Edit button and rename the app, for example, CRMSalesForce.
  5. To change the icon, click the default icon and provide your custom icon. For more information about adding applications, click here.

Configuring Identity

Identity is a service that validates the authentication of your users before they can access your application. Kony MobileFabric allows various types of validations that include:

For your CRM app, you will be using Salesforce Authentication.

To add an identity service, follow these steps:

  1. Navigate to the Identity tab (default selection) in app configuration page.
  1. Click Add New Identity Service and select Configure New.
  2. Provide an identity name, for example, SFIdentity.
  3. From the Type of Identity drop-down list, select Salesforce as you are authenticating users against Salesforce in your CRM app.
  4. From the Auth Mode drop-down list, select the UserName/Password
    The URLs for Salesforce URL and Callback URL for Kony MobileFabric application are pre-populated.
  5. Provide the Salesforce ClientID and the Salesforce ClientSecret details that you saved from your Salesforce Account Configuration.
  1. Click Save to save your identity configuration.

To learn more on adding identity services, click here .

Configuring Integration

The Integration tab is where you configure services for your application.

To configure integration, follow these steps:

  1. To add integration services, navigate to the Integration tab in the App Configure page.
  2. Click Add Integration and select Configure New.
  3. Provide a name for integration service, for example, SFAccounts, by hovering the mouse on [Specify a name] field and clicking the Edit button.
  4. From the Endpoint Type drop-down list, select Salesforce.
  1. Under Select Authorization Service, select the Use Existing Identity Provider option, and then select the existing identity provider from the drop-down list. This will link your integration services to your existing identity provider and authenticates Salesforce services implicitly by passing Salesforce SSO token at the backend. Provide valid UserID and Password+Security Token of Salesforce developer account where your connected application is created, and click Continue. Note: The Salesforce Password must be ap pended with the Security Token that you generated from Salesforce account.
  2. From the Object drop-down list, select the Account. The system loads available operations for the selected object in the Operation drop-down list. The system fetches all the available objects and operations associated with your Salesforce account.
  3. From the Operation drop-down list, select the getAccount, and then click the Add Operation button. In the same way you can add all the required operations under SFAccount integration service created.
  1. Click Save to save your Integration configuration. Note: In the CRM sample application, the getAccounts operation is shown as an example.
  2. To edit or test the operation, click the Settings button and select Edit. In the window that opens, you can see that required metadata to run and test the service is already populated. Note: Click Sample Code () option to see the sample code for how to make an integration service in different platforms.

You can see Input parameters querystring required to call the service in Input tab.

You can see in the Output tab that all output parameters from the service and respective Xpath to parse the params from the Service response are pre-configured.

Note: You can add the param by clicking the Add button or delete by selecting the param and clicking the Delete button.

In the Advanced tab “HTTP headers”, you will notice that SFToken is pre-populated for Authorization header to enable service testing from Kony MobileFabric console.

Provide the test value for querystring under the Input params tab and click the Test button to see the response and result. Here are sample queryString params for:

SELECT name,type,BillingCity,BillingState,AnnualRevenue,website,Industry,phone,BillingStreet from Account where type!=null
SELECT ID,NAME,FIRSTNAME,LASTNAME,TITLE,PHONE,EMAIL FROM Contact
SELECT ID,NAME,FIRSTNAME,LASTNAME,TITLE,PHONE,EMAIL FROM Lead
SELECT name,Amount,CloseDate,Type,LeadSource,StageName,ExpectedRevenue,Probability from Opportunity

Configuring Synchronization

To add Synchronization service to Kony MobileFabric environment, follow these steps:

  1. Navigate to the Synchronization tab in App Configure page.
  2. Click Add Synchronization Scope and select Configure New.
  3. Under Sync Scope Definition, do the following:
    1. In the Namespace text box, provide a name for your sync scope.
    2. From the Integration Service drop-down list, select the service that you want to connect via sync server. Leave all the other settings to default.
  4. Click Save to save your sync scope.
    To learn more about defining sync scopes and objects, click here.
  5. Under Sync Objects, all the available objects are listed. Select the required operation to be executed through sync and click Generate attributes.
  1. You can edit the attribute properties as required. You can add relations or filters in the respective tabs and click Save.
    In the sample application, you will be creating syncScopes for updateContact and getContact. If you have selected the Change Tracking Columns in Sync Scope definition, make sure that you are setting the last modified and soft delete attributes in the Change Tracking section of Sync Objects. Note: Sync is supported for Kony Studio and PhoneGap only. You can click Valid Sync Configuration to check whether Sync configuration defined is valid and to download the error log if any. For more information about Synchronization, click here.

Configuring Messaging

To configure Messaging for your Kony MobileFabric console, you need GCM key for Android and push certificates for iOS to register with Android and Apple push servers.

  1. Under Messaging, provide the GCM Key for Android, and click Save.
  1. For iOS, select the Application mode; upload the push certificates for iPhone, provide your certificate password, and click Save to save your configuration. To learn more on how to set up messaging environment on Kony MobileFabric portal, click here .

Publishing Services

After Kony MobileFabric configuration, publish services to cloud development server.

To publish services in MobileFabric, follow these steps:

  1. Navigate to the Publish tab under App Configuration page. All the available environments in your cloud account are listed.
  2. Click the environment name where you want to publish your services and click Publish.
    The publish progress can be seen by expanding the Details tab that appears at the bottom of the page. If publish is successful, you will see Published message under the environment you selected. You can access runtime services console for Integration, Sync, Messaging and Orchestration from here.
  1. To access app services console, click the icon in Runtime services displayed under the environment where you published your services. You can also access synchronization and messaging consoles by clicking respective icons.
    In the App services console, within Integration Services, you can see all your integration services you configured in your Kony MobileFabric console. You can also test your runtime services here.
  2. Select an operation, getAccount, from the SFAccount integration service to see the environment URL where the service got published. Click the link to open service details page where you can test your runtime service by providing the accesstoken, instance URL and the queryString. You can get the instance URL and accesstoken from your Kony MobileFabric test service console or execute the below Curl command in your Windows or Linux command prompt to get access token and instance URL.
  3. Curl command

    curl https://login.salesforce.com/services/oauth2/token -d "grant_type=password" -d "client_id=" -d "client_secret= " -d "username=" -d "password="
    https://login.salesforce.com/id/00D90000000wUnjEAE/00590000002rDioAAE","issued_at":"1407249996807","token_type":"Bearer","instance_url":"https://ap1.salesforce.com","signature":"GQ6LUKMW+e1cRBchfFKpzUxzcRZ0+QJ1JVWhjOcvN2s=","access_token":"00D90000000wUnj!AREAQLbHzrILpxIySJkIBHsf6Op.BvrMdtRHTLfasA_Jpd9M1.Pv5woAIlezlHdY_HUT51AjM5udLi9Y1yLUS1UU7PmBBGnq">

    Sample Code to make Kony MobileFabric client initialization call from your app

    To make Kony MobileFabric client initialization call from your app, follow these steps:

    1. To see how to make Kony MobileFabric client initialization call from your application on different platforms, click under the app name after successful publish.

    2. In the Sample Code window that appears, select the environment from drop-down list where the app is published. The sample code for initialization is generated.
    3. Click the respective platform tabs to see the initialization call signature. Important: Ensure that you make a note of “App ID”, ”App Secret” and “Service_URL”. These details are required to authenticate your application against Kony MobileFabric. The App service document and Sync Client code for PhoneGap and Kony Studio can be downloaded by clicking on the download icon () next to the published environment name. The app key and app secret can also be viewed by clicking on the Key icon () next to environment cloud name in the Publish screen.

    Downloading Kony MobileFabric SDKs

    Now that you have set up the Kony MobileFabric and published application to cloud, you will need to download Kony MobileFabric SDKs to start developing the applications.

    To download required SDKs, navigate to SDKs section in the Manage Apps page, and then click required platform icon to download respective SDKs.

    Note: Presently Kony supports Kony MobileFabric SDKs for native iOS, native Android, PhoneGap, JavaScript and Kony Studio.

    Working with Kony MobileFabric

    The first thing is to get a design for the application. You can use Kony Visualizer to design your application. To learn more on Visualizer, follow Visualizer tutorials and Documentation.

    After you have got a design, develop it for different platforms by using your choice of a programming language or tool.

    Conclusion

    In this tutorial, you have learned how to set up Kony MobileFabric, create an application with Salesforce authentication for iOS, Android, PhoneGap and Kony Studio by using Kony MobileFabric.

    Github location for the apps: