📜 ⬆️ ⬇️

What does the Titanium SDK update to version 2.0 carry?

Greetings to all supporters and fans of cross-platform mobile application development using the Titanium framework. On April 16, 2012, Appcelerator announced the upgrade of the Titanium Mobile SDK to version 2.0.1, coupled with the update of Titanium Studio, all to the same version 2.0.1. Slightly more details under the cut.


According to the developers from Appcelerator, in addition to fixing more than 700 bugs identified in previous versions, Titanium Mobile SDK 2.0.1 is based on the strengths of the previous version 1.8, and also includes a number of interesting innovations:

More I would like to dwell on such goodies as integration with the Appcelerator Cloud Service (ACS).

It's no secret that comfortable use of mobile devices involves 2 things:
  1. Extensive mobile client capabilities, including both general and device-specific functionality.
  2. Opportunities associated with cloud technologies, allowing the end user to access content without being tied to a device, as well as allowing interaction with devices of other users and access to their local content. Now this is possible with ACS.

Appcelerator Cloud Services provides the developer with a wide range of automatically scaling network capabilities. Tasks such as push notifications, user authorization, user photo management, photo collections, user status acquisition and updating, which usually require server programming or integration with multiple SDKs, are now done through a single plug-in interface.
')
According to the developers of Titanium, they took care of the stable operation of databases, file storages, search engines and application stacks, so that we can focus on what really matters: our applications and the users of these applications.
Today out of the box are available:

Currently, features marked as beta are not available from the Titanium.Cloud module, but they can be accessed using the REST API.

In addition, ACS is available to all mobile application developers, regardless of the technology with which these applications are developed. Those. it doesn't matter how we create our application, whether it be Titanium, Objective-C, Java, Sencha Touch or PhoneGap. Any technology that allows making an HTTP request can easily use ACS as a backend server.

In order to use ACS in our application, we need to perform the following four steps:

1) App registration with Appcelerator Cloud Services


If we create a new project in Titanium Studio and at the same time activate the corresponding checkbox - the application in Appcelerator Cloud Services is registered automatically. You can see it on the " My Apps " page in our account on the Appcelerator Developer Center . If the checkbox has not been activated, then you can manually register the application later on everything on the same page " my applications ".

When registering the application, unique OAuth Consumer Key, OAuth Secret and App Key will be generated, which we will need to use in further developing the application.

2) Connecting Appcelerator Cloud Services module


ACS support is built into Titanium. However, in order to use it, we must use the require () directive in any file convenient for us to connect the ACS module to our project:
var Cloud = require('ti.cloud'); Cloud.debug = true; // .      false 

You also need to not forget about tiapp.xml and make sure that the following directive is there:
 <modules> <module platform="commonjs">ti.cloud</module> </modules> 


3) Authentication


To ensure the safety of connections and in order to exclude options where someone impersonates us and sends requests to ACS, our application must prove that it has the right to communicate with ACS. Secure access is provided through two-step OAuth authentication. This is the process by which the Consumer Key and OAuth Secret are used to “sign” each request of our application. When the ACS server receives the request, OAuth Secret is used along with the data presented in the request to calculate the control signature. If the sent and calculated signatures match, the request will be processed.
In order for our application to successfully “introduce itself” to the server, you need to add the following lines to the tiapp.xml file:
 <property name="acs-api-key" type="string">get_from_app_admin_page</property> <property name="acs-oauth-key" type="string">get_from_app_admin_page</property> <property name="acs-oauth-secret" type="string">get_from_app_admin_page</property> 


4) Directly use the API in the application code


A few examples:

4.1) Creating a user:

 Cloud.Users.create({ username: username.value, password: password.value, password_confirmation: confirmPassword.value, first_name: firstName.value, last_name: lastName.value }, function (e) { if (e.success) { //    } else { //   } }); 

4.2) Photo publishing:

 // ,      .       . // collectionID  ID       Cloud.Photos.create({ photo: photo, collection_id: collectionID, 'photo_sync_sizes[]': 'small_240' }, function (e) { if (e.success) { //         photo = null; collectionID = null; } else { //   } }); 

4.3) Connecting FaceBook Login to our application:

 //    Facebook     //  ,     function updateLoginStatus() { if (Ti.Facebook.loggedIn) { label.text = 'Logging in to ACS as well, please wait...'; Cloud.SocialIntegrations.externalAccountLogin({ type: 'facebook', token: Ti.Facebook.accessToken }, function (e) { if (e.success) { var user = e.users[0]; alert('Logged in! You are now logged in as ' + user.id); } else { error(e); } }); } else { label.text = 'Please login to Facebook.'; } } //         FaceBook Ti.Facebook.addEventListener('login', updateLoginStatus); Ti.Facebook.addEventListener('logout', updateLoginStatus); //    Facebook win.add(Ti.Facebook.createLoginButton({ top: 10 })); 


On the one hand - some advantages! So far, the only minus found is that the free version of ACS is available only until June 1, 2012. This is also reported in one of the posts of Appcelerator developers.

The persistent impression is created that the guys from Appcelerator in the field of application development organizations are aggressively chasing the guys from Apple. Judge for yourself: each developer must register if he wants to use Titanium, his own development environment is provided, thanks to which each developed application is fixed and statistics are kept on it, there is a store of modules, etc.

On this, in fact, everything. Thanks for attention.

Sources:

Source: https://habr.com/ru/post/143325/


All Articles