I asked a question yesterday regarding the usage of cordova plugins. I solved the problem by creating my project from scratch. But when I add a new plugin again. The new plugin doesn’t work although the old plugin still work. Here are my steps:
Create a new project
ionic start myproject blank --v2
Add the social share plugin
cordova plugin add cordova-plugin-x-socialsharing
Add my code related to social sharing and build it for ios
ORIGINAL EXCEPTION: TypeError: undefined is not an object (evaluating ‘ionic_1.cordova.InAppBrowser’)
But my social share plugin still work!!! It looks like the new plugin is not hooked up to my project at all.
If I start a new project and add plugin for InAppBrowser, everything is fine. So it’s not the problem of plugin itself. Can anybody help to explain how ionic 2 hook up the plugin to project? Why can’t add new plugin? Thanks.
Ionic is a framework on top of Cordova. If you’re using Ionic, you’re basically using Cordova. The Ionic build process will eventually call the Cordova build process, but it does other work as well. In general when working with Ionic you should use the Ionic versions of the commands strictly and just pretend the Cordova variants do not exist.
First, what kind of error?
Second, try using the build command when you install each plugin, it seems it has solved some issues for other plugin users.
@luchillo17 Got it working!! The function I was using was not available in IOS. After loading the pulgin the global ble is accessible just as it was described in the other thread using the camera. It would be nice to get the definitions working in typescript. I have been just declaring the global like this
declare var ble : any;
But you don’t get any of the functions or proprieties. When you define a interface in typescript with the same name as the global in the pulgin will it overwrite the variable?
What your looking for is a “.d.ts” or “type definitions” file. This may or may not be supplied by the source code author, otherwise will probably need to be hand-written.
How did you load globally the plugin? Can you share your controller code including imports? I think i’m dealing with the same issue with cordova-plugin-googlemaps, but i can’t figure out how to do it
I didn’t need any import statements the global defined in plugin can now be used anywhere in the code.
This plugin looks a lot more complicated than the bluetooth one. I have not tried to use it so I am just guessing.
Try
Then see if you get access to the plugin.google.maps variable. Keep in mind that your editor will have no idea about the variable and it will not exist until it’s been build and running on the particular device or maybe the simulator. Best of luck