Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

ACS User Search Not Finding Users

$
0
0

I am trying to conduct a user search and then show the filtered results as rows in my tableview. I followed the ACS documentation on searching for users with the 'q' parameter, but for some reason it doesn't find any of the users. I constantly receive 0 users found. Code below:

findFriends.js:

function findFriends(){
 
    var findFriends = Ti.UI.createWindow({ title: 'Profile Settings',
            barColor:'#e67e22',
            backgroundColor: '#fff',
            translucent: false});
 
var data = [];
 
var searchBar = Ti.UI.createSearchBar({
    top:0,
    height:50,
    showCancel: true,
    hintText: "search for whatever"
});
 
findFriends.add(searchBar); 
 
var tableView = Ti.UI.createTableView({
    top:50,
    data: data.users
});
 
findFriends.add(tableView);
 
for (var i = 0; i < data.rows.length; i++){
    var row = Ti.UI.createTableViewRow({
 
});
 
tableView.add(row);
 
data.push(row);
}
 
 
 
searchBar.addEventListener('return', function(e){
    Cloud.Users.search({
    q: 'username',
}, function (e) {
    if (e.success) {
        tableView.setData(data);
 
        alert('Success:\n' +
            'Count: ' + e.users.length);
        for (var i = 0; i < e.users.length; i++) {
            var user = e.users[i];
            alert('id: ' + user.id + '\n' +
                'first name: ' + user.first_name + '\n' +
                'last name: ' + user.last_name);
         }
    } else {
        alert('Error:\n' +
            ((e.error && e.message) || JSON.stringify(e)));
    }
});
});
 
 
 
 
    return findFriends;
}
 
module.exports = findFriends;

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>