4

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?

Alex Bailey
  • 1,260
  • 12
  • 27
  • There is no need for specific Angular support. Firebase and others work fine with Anglar. If you run into specific issues create a new question. – Günter Zöchbauer Mar 06 '16 at 12:57
  • I can't seem to get the two working. Do you know of a working example of Firebase working with Angular 2 or Ionic 2? I've googled around for a day or two but with no luck. – Alex Bailey Mar 06 '16 at 13:02
  • If you can't get it working this might even be a proper question for StackOverflow if you would add the code to your question that shows what you tried, the error message you got, the current and expected behavior. http://stackoverflow.com/help/how-to-ask, http://stackoverflow.com/help/dont-ask, http://stackoverflow.com/help/on-topic, http://meta.stackoverflow.com/questions/260648/stack-overflow-question-checklist – Günter Zöchbauer Mar 06 '16 at 13:06
  • 1
    I've updated to include code. I thought it needed to be a lib specifically built for Angular 2. Hence the reason I didn't include code. – Alex Bailey Mar 06 '16 at 13:13

2 Answers2

3

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.

Alex Bailey
  • 1,260
  • 12
  • 27
0

Batch.com is offering a Push Notification service for Firebase

https://batch.com/parse-replacement-with-firebase

Aral Roca
  • 5,442
  • 8
  • 47
  • 78
  • Thanks this answers half the problem. Have you any idea how to get this working with an Angular 2 project easily? I just can't seem to understand how to import it in to the right files in the right places. – Alex Bailey Mar 06 '16 at 13:04
  • Well, I not have experience with Batch with Angular2. But If you use Ionic 2 maybe the documentation about Cordova is just that you need: https://batch.com/doc/cordova/prerequisites.html I'm not sure, but I hope this helps you. Otherwise, you can implement Firebase in angular2 using this: https://www.npmjs.com/package/angular2-firebase – Aral Roca Mar 06 '16 at 13:12
  • Sorry, I can't help you more. I hope you find soon the solution :) – Aral Roca Mar 06 '16 at 13:27