Ionic 2 with ng-cordova

You are running in tablet, connected with usb for debugging and used ionic run android to install?
If the Storage: SQLite plugin not installed, falling back to WebSQL. Make sure to install cordova-sqlite-storage in production! keeps showing in the logs then there’s an error installing the plugin or generating the apk, but not much i can infer from here.

im working with iOS.
ionic build > connected with usb > xcode run > inspect with safari

i’ve removed and installed again the SQLite and the platform…

thanks!

Thanks? did it worked?

sorry, didn’t.

i’m still working on that but im having some memory issues when i load the data from the database.
on iOS every time crash with “memory warning”.

I said thanks for your attention but i’m still working on this ( if u want we can still trying to solve this ).

I just spent some time on this so replying here. if you are using typescript, your editor/the build will report an error that navigator is undefined. It will work on the device though when the cordova plugin runs.

To fix this I downloaded phonegap.d.ts, which includes all the cordova interface definitions, added it to the project, and updated tsconfig.json to include:

“files”: [
“app/app.ts”,
“app/phonegap.d.ts”
],

that cleared up the typescript errors and gives you typing access to all the navigator attributes

2 Likes

This worked for me too :slight_smile: , “navigator” showed as undefined in the editor. @ootleman looks to have a fix for this.

When running in android emulator it pops a message showing no camera.
When running on IOS via IONIC.IO App it didn’t show up. Really not sure if ionic.io app supports cordova plugins yet.
However if you just drop your project into the phone-gap developer app the camera dialogue opens.
I don’t have xcode setup yet so i cant tell if it’s going to work natively or not? anyone done it?

I don’t need the camera, I want to get the cordova-plugin-ble-central working, but i cant seem to get access to the ble variable. any suggestions?

Hi, what’s that weird folder location for the typings file? putting them inside app means it will get transpiled, or at least that’s what looks like.

What i do is use the tsd npm package to init a tsd.json and a typings folder in the root of the app, using the tsd package let you easily install and keep up to date the tsd’s you install, and you can reference all the typings you install like this:

"files": [
  "app/app.ts",
  "typings/tsd.d.ts"
],

That tsd.d.ts will hold a reference to each tsd you install, you don’t have to worry about adding the file in the files array as good as you use the tsd command to install the ts definition.

thanks for the tip - that looks clean

Can’t speak for the cordova-plugin-ble-central plugin but the Camera plugin did work fine under xcode (only).

I ended up uploading the app and using the ionic view iOS app to test.

Do you think it will work the same with say a file that holds classes like models? i want to generate a models folder and have those clases available in all files of the app, as well as the typings.

Hi,

Do you have any sample project that Camera works with Ionic2? .

Made one here, please try out:

How can I install ionic-native? https://github.com/driftyco/ionic-native

Hi, I’m trying to use cordova inAppBrowser plugin by typing
"window.open = cordova.InAppBrowser.open;"
in my app.ts constructor but this doesn’t work, am I implementing this wrong?
I get a “cordova not defined” error.

Never mind, for anyone else with a similar problem I figured out I needed to put it outside the constructor in a platform ready callback function.

Hi joshmorony ! I just want to add some quirks…ng-cordova cleanly build with Angular-1 which is compatible with ionic 1(already built with Angular-1) .That’s why ng-cordova compatible with ionic-1. Apart from that ionic 2(built with Angular-2), that’s why ng-cordova will not use directly inside ionic-2. May be we should either wait for ng-cordova-2 for ionic-2 or just directly use simple cordova plugin which build with clean javascript.

Ionic Native is out now which is the equivalent of ngCordova for Ionic 2: http://ionicframework.com/docs/v2/native/Camera/

with

window.plugins.appPreferences;

I get an error: [ts] error: Property ‘plugins’ does not exist on type ‘Window’.

yea for some reason window.plugins doesnt exist for me either.
navigator.plugins does
cordova doesn’t

~edit
I ensured that my typings was up to date and i had installed the cordova typings correctly and now cordova comes up as allowed.

Push notifications with ionic 2
http://nishanthkabra.com/ionic2push.html