我在 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);
最佳答案
您看过这些资源吗?他们有点老了,但仍然可以帮助您解决问题:
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 plugin已被释放。我们一直致力于通过彻底重新设计 Cordova 插件来改善 Cordova 体验。
@somnathbm 尝试使用更新的插件,看看是否仍然遇到相同的问题。
关于ibm-cloud - 如何在 ionic 2 中使用 cordova 插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39512774/