I'm submitting a ... (check one with "x")
[X] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or https://ionicworldwide.herokuapp.com/
Current behavior:
When installing ionic-native in ionic v1 and trying to incorporate given the (very spread out) directions, the following error manifests:
Uncaught Error: [$injector:modulerr] Failed to instantiate module app due to:
Error: [$injector:modulerr] Failed to instantiate module ionic.native due to:
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.
http://errors.angularjs.org/1.5.3/$injector/nomod?p0=ionic.native
at http://localhost:8100/lib/ionic/js/ionic.bundle.js:13443:12
at http://localhost:8100/lib/ionic/js/ionic.bundle.js:15409:17
at ensure (http://localhost:8100/lib/ionic/js/ionic.bundle.js:15333:38)
at module (http://localhost:8100/lib/ionic/js/ionic.bundle.js:15407:14)
at http://localhost:8100/lib/ionic/js/ionic.bundle.js:17899:22
at forEach (http://localhost:8100/lib/ionic/js/ionic.bundle.js:13696:20)
at loadModules (http://localhost:8100/lib/ionic/js/ionic.bundle.js:17883:5)
at http://localhost:8100/lib/ionic/js/ionic.bundle.js:17900:40
at forEach (http://localhost:8100/lib/ionic/js/ionic.bundle.js:13696:20)
at loadModules (http://localhost:8100/lib/ionic/js/ionic.bundle.js:17883:5)
Expected behavior:
App would run.
Steps to reproduce:
Following directions from documentation:
npm install @ionic-native/core --save # From https://ionicframework.com/docs/native/
ionic cordova plugin add cordova-plugin-advanced-http # Next two from https://ionicframework.com/docs/native/http/
npm install --save @ionic-native/http
Then, based on https://github.com/ionic-team/ionic-native/blob/v2.x/README.md updating www/js/app.js from:
angular.module('app', ['ionic', 'app.controllers', 'app.routes', 'app.directives','app.services',])
to:
angular.module('app', ['ionic', 'ionic.native', 'app.controllers', 'app.routes', 'app.directives','app.services',])
Related code:
n/a
Other information:
n/a
Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):
cli packages: (/usr/local/lib/node_modules)
@ionic/cli-utils : 1.19.2
ionic (Ionic CLI) : 3.20.0
global packages:
cordova (Cordova CLI) : 8.0.0
Gulp CLI : CLI version 3.9.1 Local version 3.9.1
local packages:
Cordova Platforms : android 7.0.0 ios 4.5.4
Ionic Framework : ionic1 1.3.3
System:
ios-deploy : 1.9.2
Node : v10.3.0
npm : 6.2.0
OS : macOS High Sierra
Xcode : Xcode 9.3 Build version 9E145
Environment Variables:
ANDROID_HOME : not set
Misc:
backend : pro
It appears that the directions for v1 are incomplete (unless they are hidden somewhere not easily found). To install ionic-native in a v1 project, you should use:
npm install ionic-native --save --prefix www/lib
Reference: https://stackoverflow.com/a/46190149/925452
Notice the prefix flag. This is the only way a v1 project can see the js file. Then the instructions should state somewhere that the index.html file will need the below line added before the ionic.js include:
<script src="lib/node_modules/ionic-native/dist/ionic.native.min.js"></script>
Spoke too soon, sorry. In emulator when trying to access $cordovaHTTP I get:
ionic.native.js:17021 Native: tried calling HTTP.post, but Cordova is not available. Make sure to include cordova.js or run in a device/simulator
Relevant section of index.html:
<title></title>
<script src="lib/ionic/js/ionic.bundle.js"></script>
<script src="cordova.js"></script>
<script src="lib/node_modules/ionic-native/dist/ionic.native.js"></script>
I have a feeling this is more an issue with documentation than with ionic-native overall, but either way it doesn't seem possible to execute given the existing setup methodologies.
And when running on a device, from adb logcat (since the above may be expected when running emulate):
07-30 15:44:35.374 4583 4583 I chromium: [INFO:CONSOLE(17012)] "Install the HTTP plugin: 'ionic plugin add cordova-plugin-http'", source: file:///android_asset/www/lib/node_modules/ionic-native/dist/ionic.native.js (17012)
I also tried
npm install --save @ionic-native/http --prefix www/lib
with no luck.
Cool, but, how can i do this in app.js in Ionic V1?
https://ionicframework.com/docs/native/clevertap
import { CleverTap } from '@ionic-native/clevertap/ngx';
constructor(private clevertap: CleverTap) { }
What would be equivalent?
For Ionic v1, you would have to use an older version of Ionic Native, as the 'ngx' version uses a later version of Angular.
Sure, but, how to import in app.js?
See this: https://github.com/ionic-team/ionic-native/tree/v2.x#angular-1
You will probably want to reference the v4 of Ionic Native. You will need to change your npm installs to reference that version.
Thanks! I'm triying to use CleverTap Cordova in Ionic V1. This implementation Hurts haha
Does anyone have the solution? ionic native 5 claims to have support for ng1, but I followed the doc and got the same error.
Hey @gustavoborboleta I answered that question on stackoverflow.