Titanium Cloud ServiceTitanium Cloud Service - is a simple and convenient way to avoid creating a server for working with a mobile application, using ready-made solutions from Appcelerator.

')
Cloud Service supports the use of push notifications, sending e-mails, storing large amounts of photos and more.
It should be noted that there are several
tariff plans for the Cloud, but to start the free version is more than enough. This version provides such features as: 5 million Push Notifications, 5 million API calls, 20 gigabytes of free space on the server, 100 thousand e-mails per month, which, in my opinion, is very good.
In addition, there are 2 versions of working with the Cloud - this is Production and Development, which is undoubtedly very convenient. In this case, for example, when compiling an application on a device connected to a computer and using it, the application will be regarded as a development version, otherwise as a production.
Connecting to a project is easy.In turn, connecting Cloud to the Titanium Studio project is elementary. In the tiapp.xml file, you must set the Enable value for Cloud Services. The necessary keys will be added to the project, which will also be displayed on the project page at
https://cloud.appcelerator.com .
Data managementSo, to work with a project, you need to configure it on the Cloud page. All that will be needed are tabs: settings, email templates, and user creation in app management. All actions must be duplicated in two versions of the project (production and development).
What you need to send email is to work with SMTP Settings fields. Here, the username is the email from which the email will be sent, and the password is the password from this email. TLS must be set to true. In this example, I will use gmail smtp address, which looks like this at smtp.gmail.com, you can use 587 port.
Go to the email templates tab. Here you create a message template that will be sent to the final recipient. I will describe a small example:
name: order ( ) subject: Order from app ( ) body: ( ) <!DOCTYPE html> <html lang="en"> <head> <body> Name: {{name}}<br /> Surname: {{surname}}<br /> <br /><br /> {{order}} </body> </html>
As you can see, in the body of the letter there are 3 variables that will be filled with data during the application.
Finally, let's move on to the last step - creating a user. The user is required to access the Cloud from the application and transfer specific information. We press the Create user button and fill in the fields with the data that will be used in the application code, and specifically, the username and password will be needed.
Work with Titanium.Cloud APILet's get to work with the API. To begin with we will connect the necessary library in the code and make the user login, which was created in the Cloud a little higher.
var Cloud = require('ti.cloud'); Cloud.Users.login({ login : 'username', password : 'password' }, function(e) { if (e.success) { ... } } });
If the user login was successful, you should start uploading images to the server. At this stage, you should save the image id in any variable, to further check this image for its processing by the server, since this may take a different amount of time and it may happen that the program runs faster than the server.
var currentItem = Ti.Filesystem.getFile(pathToFile); var blob = currentItem.read(); Cloud.Photos.create({ photo : blob }, function(e) { if (e.success) {
Now, directly, we will make a check on the image processing by the server and if everything is successful, we will move on to the function of sending an email.
Cloud.Photos.show({ photo_id : id }, function(e) { if (e.success) { Cloud.ondatastream = function(e) { messageLabel.text = L('server_processes_data'); } var photo = e.photos[0]; if (photo.processed) { sendEmail(); } });
Consider the function of sending letters. Here, the template is the name on the Cloud page in the email templates tab, recipients is the recipient of the letter. Name, surname and order are the variables described in the email templates template, respectively.
function sendEmail() { Cloud.Emails.send({ template : 'order', recipients : 'someone@gmail.com',
Letters reach quickly, without any delay.
Thus, Appcelerator Cloud is convenient for connecting to projects and for further use, and its free version has all the features to become familiar with and get started with this product.