4

几天来,我一直在尝试寻找与 Angular 2(我正在使用 Ionic 2)一起使用的 MBAAS。Parse 正在关闭,所以这对我来说并不是一个真正的选择,我尝试过的其他人(Firebase、Backendless 等)似乎还没有 Angular 2 SDK。

可能是我不耐烦了,但我现在真的很想开始使用它,但我不能没有像样的 SDK。

是的,如果我真的想要的话,我也可以使用 REST API,但我觉得这会限制应用程序需要的简单推送通知等的能力。

所以问题是:有谁知道支持 Angular 2 并且有一个可用于支持推送通知和数据存储的库的 MBAAS?

编辑:

因此,例如,尝试在 Angular 2 中使用后端 mbaas,我尝试了以下方法:

结构:

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

应用程序.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' );

    });
  }
}

这给出了错误:“无法读取未定义的属性'initApp'”,这表明我没有正确导入 js 库。你能帮忙解释一下为什么会这样吗?

4

2 回答 2

3

因此,经过大量更改、删除、添加和谷歌搜索,我找到了一种有效的方法。下面是方法。如果这不是正确的方法或有更好的方法,请告诉我。

在使用 backendless 的示例中,首先通过 npm 安装它:

npm install backendless

现在在 app.js 的顶部添加:

import 'backendless';

现在您可以轻松地在该文件中使用它。例如。

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

我猜你必须将它导入到你想使用的每个页面,但不确定那个页面。

于 2016-03-06T13:55:28.563 回答
0

Batch.com 正在为 Firebase 提供推送通知服务

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

于 2016-03-06T13:00:47.043 回答