javascriptangularionic2mbaas

Angular 2 MBAAS


I've been trying to find a MBAAS that works with Angular 2 (I'm using Ionic 2) for a few days now. Parse is shutting down so that's not really an option for me and the others I've tried (Firebase, Backendless etc.) don't seem to have an Angular 2 SDK out yet.

It might be me being impatient but I really want to start working with this now but I can't without a decent SDK.

Yes I can use REST API's if I really wanted too but I feel that would limit the ability for simple Push Notifications etc. which will be required by the app.

So the questions is: Does anyone know of a MBAAS that supports Angular 2 and has a lib available to support Push Notifications and Data Storage?

Edit:

So for example, trying to use backendless mbaas in Angular 2, I've tried the following:

Structure:

 - app
 - app.js
 - backendless.js
 -- pages
 --- home
 ---- home.html
 ---- home.js
 ---- home.scss
 -- theme

app.js

import {App, Platform} from 'ionic-angular';
import {HomePage} from './pages/home/home';
import {Backendless} from 'backendless';

@App({
  template: '<ion-nav [root]="rootPage"></ion-nav>',
  config: {} // http://ionicframework.com/docs/v2/api/config/Config/
})
export class NotOnFileApp {
  static get parameters() {
    return [[Platform]];
  }

  constructor(platform) {
    this.rootPage = HomePage;

    platform.ready().then(() => {
      // The platform is now ready. Note: if this callback fails to fire, follow
      // the Troubleshooting guide for a number of possible solutions:
      //
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      //
      // First, let's hide the keyboard accessory bar (only works natively) since
      // that's a better default:
      //
      // Keyboard.setAccessoryBarVisible(false);
      //
      // For example, we might change the StatusBar color. This one below is
      // good for dark backgrounds and light text:
      // StatusBar.setStyle(StatusBar.LIGHT_CONTENT)

      Backendless.initApp( 'XXXXX', 'XXXXX', 'v1' );

    });
  }
}

This gives the error: "Cannot read property 'initApp' of undefined" which suggests that I haven't imported the js library correctly. Can you help with why this might be?


Solution

  • So, after much changing, removing, adding and googling I've found a method that works. Below is the method. Please let me know if this isn't the correct way to do this or there is a better way to do this.

    In the example of using backendless, start by installing it through npm:

    npm install backendless
    

    Now at the top of app.js add:

    import 'backendless';
    

    Now you can easily use it in that file. eg.

    Backendless.initApp( 'XXXXX', 'XXXXX', 'v1' );
    

    I'm guessing you'll have to import it in to every page you want to use but unsure on that one.