如何在ionic 2中使用cordova插件。

3

我在Ionic 2项目中使用第三方cordova插件时遇到了问题,其中一些插件不在Ionic Native中可用。据我所知,那些不在Ionic Native之内的插件,我不需要导入它们,因为它们是直接可用的。

我正在使用ibm-mfp-core (https://www.npmjs.com/package/ibm-mfp-core) 插件。我想要使用BMSClient.initialize()方法来初始化IBM Bluemix SDK。此外还有一些其他内置方法,但是它们都不在cordova.plugins中可用。

以下是代码片段:

import { Component } from '@angular/core';
import { Platform, ionicBootstrap } from 'ionic-angular';
import { StatusBar } from 'ionic-native';
import { TabsPage } from './pages/tabs/tabs';

declare let cordova:any;

@Component({
  template: '<ion-nav [root]="rootPage"></ion-nav>'
})
export class MyApp {

  public rootPage: any;

  constructor(private platform: Platform) {
    this.rootPage = TabsPage;

    platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      StatusBar.styleDefault();

      // initialize IBM BLuemix SDK
      //BMSClient.initialize("https://pearl.mybluemix.net", "1a1ab2e9-4f5a-4db6-9ba3-2da97349a160");

      typeof cordova.plugins.MFPCore != 'undefined'?alert('MFP found'):alert('MFP NOT found');
    });
  }
}

ionicBootstrap(MyApp);
1个回答

0

你看过这些资源吗?它们有点老了,但仍然可能能帮助你解决问题:

https://developer.ibm.com/bluemix/2016/01/20/bluemix-mobile-client-access-services-in-ionic-apps/

https://www.youtube.com/watch?v=UObmJQtxixs

如果这些不能帮助您,请告诉我。

更新

截至今天,一个新的bms-core插件已经发布。我们一直在努力改进cordova体验,通过彻底改造我们的cordova插件。

@somnathbm尝试使用更新的插件并查看是否仍然遇到相同的问题。


您IP地址为143.198.54.68,由于运营成本限制,当前对于免费用户的使用频率限制为每个IP每72小时10次对话,如需解除限制,请点击左下角设置图标按钮(手机用户先点击左上角菜单按钮)。 - somnathbm

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接