Skip to content

Latest commit

 

History

History
112 lines (83 loc) · 3.63 KB

README.md

File metadata and controls

112 lines (83 loc) · 3.63 KB

Patch includes:

How to use:

-|
 |-backendless.js
 |-backendless-appcelerator.js
 
  • include the patch to your code before using any Backendless API
//index.js file of your app
...

require('.../path-to/backendless-appcelerator')

Backendless.initApp(...)

...

Polyfill for Promise

The patch includes polyfill for Promise, so you can feel free to use it your code

Backendless namespace in global scope

The patch adds Backendless namespace in global scope, so be free to use Backendless without additional require Backendless JS-SDK, just require the patch at once in the top of your index file and use Backendless namespace in any files

Override Backendless.XmlHttpRequest

The patch override Backendless.XmlHttpRequest by Ti.Network.createHTTPClient. You don't need add this fix manually anymore.

before:

Backendless.XMLHttpRequest = function () {
  return Ti.Network.createHTTPClient();
};

after:

//do nothing

Correct File Upload

Appcelerator ENV has little differences with Web and Nodejs environments, so the patch fix it.

Examples:

function uploadTextFile() {
  var textFile = Ti.Filesystem.getFile(Ti.Filesystem.tempDirectory, 'my-text-file.txt');
  textFile.write('Hello world!');

  Backendless.Files.upload(textFile, 'text-files-directory', true)
    .then(function (result) {
      Ti.API.info('fileURL: ' + result.fileURL);
    })
    .catch(function (error) {
      Ti.API.error(error);
    });
}
function uploadImgFileFromPhotoGallery() {
  Titanium.Media.openPhotoGallery({
    success: function (event) {
      var imageFile = Ti.Filesystem.getFile(Ti.Filesystem.tempDirectory, 'my-image-file.png');
      imageFile.write(event.media.imageAsResized(100, 100));

      Backendless.Files.upload(imageFile, 'img-files-directory', true)
        .then(function (fileURL) {
          Ti.API.info('fileURL: ' + JSON.stringify(fileURL));
        })
        .catch(function (error) {
          Ti.API.error(error);
        });
    }
  });
}

Below are a few links to help with the development:

We would love to hear from you. Please let us know about your experiences using Backendless. You can reach us through the support page at http://support.backendless.com or email: [email protected]

Thank you and endlessly happy coding!
The Backendless Team