Using Cordova FileTransfer in an ionic 2 app - angularjs

I want to do file uploads in my ionic 2 app.
In my code I have:
var ft = new FileTransfer();
But FileTransfer is not recognised.
I have installed the Cordova file transfer plugin using:
cordova plugin add cordova-plugin-file-transfer
How do I import FileTransfer from the plugin so it is available.
I am using Angular 2 not Typescript.

Ensure to include cordova.js file in your respective html. Also register deviceready event listener and invoke plugin inside the listener.
In case of ionic platform, use platform.ready() which is an equivalent wrapper for deviceready event.
ionic.Platform.ready(function(){ //logic to invoke plugins });

Related

How to import ionic-native into an Ionic1/AngularJS project?

I'm working on a project with Ionic v1 and AngularJS and Cordova.
I'm trying to include this firebase plugin in my project with no luck so far: https://github.com/dpa99c/cordova-plugin-firebasex
I was told to try out this node module: https://github.com/ionic-team/ionic-native#angularjs
However, I keep getting this error:
Error: [$injector:nomod] Module 'ionic.native' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
<script src="../node_modules/#ionic-native/core/ionic-native-plugin.js"></script>
How can I make this work in my project and how can I import ionic-native properly?
Actually, I'm using ionic-native 5.23.0 in my angularJS project and I believe all 5.x versions have support for this angular version. If you take a look in ionic-native/core you will notice that exists a file called ng1. That file have a function called initAngular1 who iterate across object's properties creating angularJS services. Here's what I did.
First, I opened the script that I use as entry point in my webpack.config to create a bundle (Since I already had webpack installed, I used)
Inside this script, I wrote the following:
require('#ionic-native/core');
const appVersion = require('#ionic-native/app-version');
const sqlite = require('#ionic-native/sqlite');
const statusbar = require('#ionic-native/status-bar');
const toast = require('#ionic-native/toast');
const ng1 = require('#ionic-native/core/ng1')
ng1.initAngular1({
AppVersion: appVersion.AppVersion,
SQLite: sqlite.SQLite,
Statusbar: statusbar.StatusBar,
Toast: toast.Toast
});
Run webpack
Inject ionic.native module in your app.
Inject any plugin you would like to use with a $cordova prefix.
angular.module('myApp', ['ionic.native'])
.controller('MyPageController', function($cordovaToast) {
$cordovaToast.show('Hello from Ionic Native', '5000', 'center');
});
Don't forget to install the cordova plugin used by the ionic-native plugin.
ionic-native stopped the support to angular ionic v1/angular 1,
https://github.com/ionic-team/ionic-native/tree/v3.x
For Ionic V1/Angular 1 support, please use version 2 of Ionic Native. See the 2.x README > for usage information.

How to import angularjs plugins manually in Eclipse?

I'm trying to create basic login page in AngularJS. I've tried to add Angulajs plugins via eclipse market place, but i couldn't do that.
Now i downloaded the plugins from site. How can i import the plugins to eclips?
Use the files and Inject into the module.
app.module('modulename',['<inject the third party app/plugin>'])
include all the js-files needed in that plugin in ur html page. Use the controller and itsfunctions.

How to use ace plugin in ionic application?

I have added the ace plugin ionic (ionic plugin add cordova-plugin-ace). But i tried to access the
if (ace.platform == "Android")
but its gives me following error:
error:ReferenceError: ace is not defined
when i tried to use:
if (window.ace.platform == "Android")
I am getting this error:
platform is not defined to undefined ace.
please help me how to use ACE plugin in my application?
In vanilla cordova app, we use to invoke the plugin code inside deviceready event listener and in ionic framework platform ready is the equivalent of Cordova deviceready event.
Invoke plugin code inside platform ready which ensures that the cordova and plugins are loaded completely.

grunt serve:dist error with Backbone jQuery Mobile RequireJS

I'm new to Grunt and the distribution process. I have a Yeoman generated app using the backbone generator, require.js and jQuery Mobile. It works fine with 'grunt serve' but when I run through the build and serve:dist, clicking on the jQuery Mobile / Backbone href links does not respond. I'm using backbone routing.
If I manually type the href URL, it works. If I do an Inspect Element on the href and click on the URL in the debug window, it also works.
Something must not be getting included in the dist but I'm at at loss as to what is missing and why. I don't have any errors in the console.
Here's my Gruntfile: http://codeshare.io/pHbSc
Make sure almond is being used. See https://github.com/gruntjs/grunt-contrib-requirejs/blob/master/docs/requirejs-examples.md
The jQuery Mobile settings to disable it's own link binding handler were being set correctly when run under require.js and grunt but not with almond. I was setting these values on mobileinit:
define(['jquery'], function ($) {
$(document).on("mobileinit", function () {
But the mobileinit call was never being made under almond. I moved the settings to my Backbone main.js file and now they're being set and the Backbone routing is working
$.mobile.linkBindingEnabled = false
$.mobile.hashListeningEnabled = false

How to add Cordova barcodescanner plugin sencha touch2.3

I am initializing cordova in my app which was using touch2.3 and added barcodescanner.js file in app.json and build it successfully using sencha app build native.I loaded .apk file in my android and trying to run,when I hit scanner button it is raising an alert saying cordova/plugin/BarcodeScanner not found.I updated config.xml . How to add custom cordova plugins to new Sencha tocuh2.3?.Please help me on where I was going wrong.Any help would be appreciated.Thank you
Download the repo using GIT or just a ZIP from Github.
Add the plugin to your project (from the root of your project):
go to your cordova or phonegap folder run follwing cmd
cordova plugin add
then run beloows for check
cordova plugin ls
I tried following these instructions without success and let me be more specific:
created sencha 2.3 app called myscan
added Cordova (not Phonegap) with Sencha cordova init
cd to Cordova folder
added the plugin
cordova plugin add https://github.com/wildabeast/BarcodeScanner
5 build the app with sencha app build native
6 created a simple test
Ext.device.Scanner.scan(function(c) {
alert("We got a barcode\nResult: " + c.text + "\nFormat: " + c.format + "\nCancelled: " + c.cancelled)
}, function(c) {
alert("Scanning failed: " + c)
})
I was not surprised to see that Ext.device was not defined as all the example code I could find use the navigator object so I looked at the WildaBeast sample code and changed the call to
Cordova.plugins.barcodeScanner.scan ... Now everything is defined and I trace into the code and seems to make the call into IOS but nothing meaningful results and no callbacks are called.
Now Gigi are you using Sencha Cmd v4.0.1.45
after installed barcode scanner plugin use sencha plugin Ext.ux.mgd.device.Scanner

Resources