Ads

Sunday, September 23, 2012

ACS Social Integration

Do you know, How to create ACS cloud user account using Facebook login?
Yes, we can do using ACS Social Integrations.

The external account login will create a ACS Services account if it hasn't been created, otherwise, it will login using the user who has the matching external account info.

STEP 1 - Facebook login in Titanium App 
Use below sample code for Facebook login

STEP 2 - Social Integration
After successfull login with Facebook, you will get Facebook accessToken, you can retrive this token using "Ti.Facebook.accessToken".

To integrate your facebook account with cloud, you need to pass three parameters to "Cloud.SocialIntegrations.externalAccountLogin" method,

id - External account's user id, optional for facebook. ACS server will obtain the uid using facebook token if id is missing
type - Type of the external account social media like Facebook, LinkedIn, Twitter(Currently only facebook token will be validated by the ACS server)
token - Token provided by the external account
add SocialIntegrations in Facebook login event listener

After the successful ACS Social Integrations go to
https://my.appcelerator.com/apps -> ypou-app -> Manage ACS -> Development -> Users
Here you will find a new cloud user account, which was created by external account login.

Other Methods
externalAccountLink - Associate an external account with an existing Appcelerator Cloud Services user account

externalAccountUnlink - Disassociate an external account from a Appcelerator Cloud Services user account.

searchFacebookFriends - Retrieves a list of Facebook Friends

References: 
http://docs.appcelerator.com/titanium/2.1/index.html#!/api/Titanium.Cloud.SocialIntegrations
https://cloud.appcelerator.com/docs/api/v1/social/loginexternal

Monday, September 17, 2012

Locking Android Orientation Mode

You can lock the orientation mode for Android in Titanium by successfully implementing the following steps :

By following the below steps you can lock the orientation mode throughout the app.

 1) Create a custom AndroidManifest.xml (copy this from original generated source
"build/android/AndroidManifest.xml")
2) Copy this on the created folder "platform/android/AndroidManifest.xml" at the top level of your project.(Inside your project root)
Locking Android Orientation Mode

3) Add this: android:screenOrientation="portrait" to all activities
4) Remove this: "|orientation" from all activities.

Here is my AndroidManifest.xml.


Here you can download the complete working project from my Github account Titanium-Android-Orientation

Wednesday, September 12, 2012

Appcelerator Titanium Alloy Framework

My Presentation About Appcelerator Alloy Frame work



Here you can download the complete working project from my Github account  Appcelerator Titanium Alloy Sample App

Tuesday, August 14, 2012

Top 5 Visited Posts

Here are the Top 5 visited post on titaniumtutorial.com based on Google Analytics stats.

Post
Appcelerator Cloud Push Notification in Android
Push Notification for Android using Appcelerator Cloud Service(ACS)
Launch third-party apps from Titanium App
Launch iOS Native(Map,Settings,Browser,..etc)/Third-party applications from our Titanium Application
Appcelerator Cloud Push Notification in iPhone
Push Notification for iOS using Appcelerator Cloud Service(ACS)
Appcelerator Cloud Service Custom Object and Query
Custom Objects using >Appcelerator Cloud Service and Query(Order by, Greater than, Less Than, Equal) the Objects
WebView in Appcelerator Titanium
WebView in Appcelerator Titanium with events explanation

Wednesday, August 1, 2012

YouTube Playlist in Titanium

In this post I am going to discuss about how to fetch YouTube playlist from a channel using Appcelerator Titanium.

YouTube offer API for category, search term, playlist, favorites, subscriptions... etc. Here you can found list of YouTube API
https://developers.google.com/youtube/getting_started

Below API will retrieve the user's playlists. This request does not require authentication
https://gdata.youtube.com/feeds/api/users/userId/playlists?v=2
* Here  userId represents YouTube username.

The above API response containing a playlists feed in XML format.
The response contains a series of <entry>  tags, with each entry describing a playlist.
Each entry contains the playlist's title, description, author and modification date as well as
<content> tag that specifies the URL for retrieving the list of videos in the playlist

Here I am  using Apple's YouTube username to fetch their YouTube playlist
var channelName = "apple";
var loader = Titanium.Network.createHTTPClient();
loader.open("GET", "http://gdata.youtube.com/feeds/api/users/"+channelName+"/playlists?v=2");

loader.onload = function() {
 var doc = this.responseXML.documentElement;
 var items = doc.getElementsByTagName("entry");
 for (var i = 0; i < items.length; i++) {
   var item = items.item(i);
   var playlist_title = item.getElementsByTagName("title").item(0).text;//playlist title
   var vid_count = item.getElementsByTagName("yt:countHint").item(0).text; //video count for this playlist
   var play_list_id = item.getElementsByTagName("yt:playlistId").item(0).text; //play_list_id
 }
};

loader.onerror = function(e) {
 alert("Error:"+e.error);
};

loader.timeout = 10000;
loader.send();

In below code I am going to retrieve all the videos in a particular playlist using playlist id.
http://gdata.youtube.com/feeds/api/playlists/playlist_id?v=2
var loader = Titanium.Network.createHTTPClient();
loader.open("GET", "http://gdata.youtube.com/feeds/api/playlists/" + playlist_id + "?v=2");

loader.onload = function() {
  var doc = this.responseXML.documentElement;
  var items = doc.getElementsByTagName("entry");
  for (var c = 0; c < items.length; c++) {
   var item = items.item(c);
   var thumbnails = item.getElementsByTagName("media:thumbnail");
   if (thumbnails && thumbnails.length > 0) {
     var media = thumbnails.item(0).getAttribute("url"); //thumbnail image
     var title = item.getElementsByTagName("title").item(0).text; //video title
     var videoId = item.getElementsByTagName("yt:videoid").item(0).text; //video id
   }
  }
};

loader.onerror = function(e) {
 alert("Error:" + e.error);
};

loader.timeout = 5000;
loader.send(); 

YouTube Playlist in Titanium
Playlist listing for Apple

YouTube Playlist in Titanium
Video List for Particular Playlist
Here you can download the complete working project from my Github Titanium YouTube Playlist

CodeStrong