+ Start a Discussion
Prakhar KPrakhar K 

salesforce sdk sample projects

Sir  I wanted to learn from SampleApps that salesforce has provided in their SDK,but the one which are posted on GitHub are full of errors and people have done so much editing even in SalesforceSDK libraries.It would be nice if you kindly post thelink or provide the original SDK Sample Apps .so that I can learn from it.

Gaurav KheterpalGaurav Kheterpal
"full of errors and people have done so much editing even in SalesforceSDK libraries" - I use the Mobile SDK day in and day out. Can you provide more details on A) errors that you see B) "so much editing even in SalesforceSDK libraries" - I am 100% sure that only the Mobile SDK team (Kevin Hawkins,  B Hariharan, Akhilesh Gupta and few others in that team) can only push commits to the Mobile SDK repos.

You may want to look at the commit history for both repos below.


Let me know if you are facing any specific errors and I'll be happy to help.

Prakhar KPrakhar K
@Gaurav Kheterpal 

In contact explorer app (Hybrid) (Android) onDeviceReady function is not firing?
After compiling and running the contact explorer sample app (hybrid), in index.html the onDeviceReady function is not firing nor it is giving any error in logCat in eclipse ADT?
I am using cordova 2.2.0.js using API 16 4.1.2 ?below is the code of index.html

    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0; user-scalable=no" />
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">

    <link rel="stylesheet" href="jquery/jquery.mobile-1.3.1.min.css" />
    <script src="jquery/jquery-2.0.0.min.js"></script>
    <script src="jquery/jquery.mobile-1.3.1.min.js"></script>

<script src="cordova-2.2.0.js"></script>

    <script src="cordova.force.js"></script>

    <script src="forcetk.mobilesdk.js"></script>

      .logWindow {display:none; width:700px;}
      .logWindow > p {padding:0px; margin:0px; word-wrap:break-word;}


    // The version of the REST API you wish to use in your app.
    var apiVersion = "v28.0";

    var forcetkClient;
    var debugMode = true;
    var logToConsole = cordova.require("salesforce/util/logger").logToConsole;

    jQuery(document).ready(function() {
        //Add event listeners and so forth here
        logToConsole("onLoad: Hii jquery ready");
  document.addEventListener("deviceready",onDeviceReady,false);                             //not firing,no error in LogCat and in console//


    // When this function is called, Cordova has been initialized and is ready to roll
    function onDeviceReady() {
        logToConsole("onDeviceReady: Cordova ready");
  //Call getAuthCredentials to get the initial session credentials
        cordova.require("salesforce/plugin/oauth").getAuthCredentials(salesforceSessionRefreshed, getAuthCredentialsError);

        //register to receive notifications when autoRefreshOnForeground refreshes the sfdc session

        //enable buttons


    function salesforceSessionRefreshed(creds) {
        // Depending on how we come into this method, `creds` may be callback data from the auth
        // plugin, or an event fired from the plugin.  The data is different between the two.
        var credsData = creds;
        if (creds.data)  // Event sets the `data` object with the auth data.
            credsData = creds.data;

        forcetkClient = new forcetk.Client(credsData.clientId, credsData.loginUrl, null,
        forcetkClient.setSessionToken(credsData.accessToken, apiVersion, credsData.instanceUrl);

    function getAuthCredentialsError(error) {
        logToConsole("getAuthCredentialsError: " + error);
<!-- load our app-specific code -->

    <script src="/inline/inline.js">
     alert('invoking callMe of inline.js ...');

      <div data-role="page" data-theme="b" id="jqm-home">
          <div  data-role="header">
              <h1>Hybrid REST Explorer (SalesforceMobileSDK + Cordova + JQM)</h1>

          <div id="#content" data-role="content">

              <p><a href="#" id="link_fetch_device_contacts" data-role="button" data-inline="true">Fetch Device contacts</a></p>
              <p><a href="#" id="link_fetch_sfdc_contacts" data-role="button" data-inline="true">Fetch SFDC contacts</a></p>
              <p><a href="#" id="link_fetch_sfdc_accounts" data-role="button" data-inline="true">Fetch SFDC Accounts</a></p>
              <p><a href="#" id="link_reset" data-role="button" data-inline="true">Reset</a></p>

              <p><a href="#" id="link_logout" data-role="button" data-inline="true">Logout</a></p>

              <div id="div_device_contact_list"></div>
              <div id="div_sfdc_contact_list"></div>
              <div id="div_sfdc_account_list"></div>

              <p id="console" class="logWindow">

Justas SerstkovasJustas Serstkovas
Hi Kumar,

I actually found http://www.salesforce.com/us/developer/docs/salesforce_platform_mobile_services/salesforce_platform_mobile_services.pdf very useful - if you use "Mobile SDK npm Packages" on page 18 (for iOS) to install forceios globaly, you will be able to use command "forceios samples" described in page 24. I am not 100% sure that I went through those samples, but generating fresh app using "/node_modules/.bin/forceios create" (dsecribed on page 99 for iOS) did help me a lot, as it bascially generates complete project where you can call API's. It looks like it's a very similar procedure on Android. 
Only thing I really needed is connected app key and URI I did create before.

Hope it helps.