+ Start a Discussion

Chatter feeds of logged in user using mobile sdk

I am playing around with the mobile sdk and in the mobile sdk sample contactExplorer, i am adding a functionality of getting the chatter feeds of the logged in user.

In my index.html

i added a href tag to display a new link to fetch the chatter feed

<p><a href="#" id="link_fetch_sfdc_chatter" data-role="button" data-inline="true">Fetch Chatter</a></p>

and in the inline.js i added the following code

$j('#link_fetch_sfdc_chatter').click(function() {
                                     logToConsole("link_fetch_sfdc_chatter clicked");
                                            forcetkClient.chatterFeedsCurrentUser(onSuccessSfdcAccounts, onErrorSfdc);

Here i am calling a function to get the feeds and pass the response to callback method onSuccessSfdcAccounts.

here is the chatterFeedsCurrentUser method on my forcetk.mobilesdk.js

  forcetk.Client.prototype.chatterFeedsCurrentUser = function(callback, error) {
alert('calling from forcetk');
    return this.ajax('/' + this.apiVersion + '/chatter/feeds/news/me/feed-items', callback, error);

Here is the onSuccessSfdcChatter method

function onSuccessSfdcChatter(response) {
    var $j = jQuery.noConflict();
    alert('Chatter success method!');
    cordova.require("salesforce/util/logger").logToConsole("onSuccessSfdcChatter: received " + response.totalSize + " Feed Items");

    var ul = $j('<ul data-role="listview" data-inset="true" data-theme="a" data-dividertheme="a"></ul>');

    ul.append($j('<li data-role="list-divider">Feed Items: ' + response.totalSize + '</li>'));
    $j.each(response.records, function(i, items) {
           var newLi = $j("<li><a href='#'>" + (i+1) + " - " + items.body.messageSegments.text + "</a></li>");

    $j("#div_sfdc_contact_list").trigger( "create" )

The issue i am facing is that chatterFeedsCurrentUser method is not calling the callback method. The alert 'calling from forcetk' is only displayed after which nothing happens. I am not sure what i am doing wrong here.

I am working on hybrid app on a android.
Hi Prady, 

Which SDK are you using, like iOs, Android, HTML5 etc...