我在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);