-
Notifications
You must be signed in to change notification settings - Fork 669
ionic serve doesn't support cordova browser plugins #354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Create stubbed version of service: Geo.service('Geolocation', function ($q){
this.getCurrentLocation = function (){
var d;
if(window.cordova){
d = $q.defer();
navigator.geolocation.getCurrentPosition(function (position){
d.resolve({
lat: position.coords.latitude,
lng: position.coords.longitude
});
}, function (){
d.resolve(DEFAULT_LOCATION);
}, {frequency:5000, maximumAge: 0, timeout: 5000});
return d.promise;
}
return $q.when(DEFAULT_LOCATION);
};
}); Make sure everything works fine in browser, run your app in live mode on emulator like $ ionic emulate android -l -c -s Use safari for iOS or Chrome for Android to debug app running on the device. |
That is certainly a solution for skipping certain features when not on a mobile device - but what if the cordova plugin contains code for a browser version as well? Then you still have to access it via Is there no way to develop without having to rebuild all the time? |
At the moment I'm trying to work around this by using the gulp file to process everything for me. I'm still surprised that you can't use a cordova plugin while developing in browser. First I manually pulled the
Then my index.html manually includes If anyone has any better ideas please let me know. |
any news about it? |
any news about it? X2 |
Hello, I'm new to ionic and it's been a wonderful experience except for the fact that I lost several hours completely stuck thanks to this issue. The 'ionic serve' experience is great and it's not at all obvious that you don't have access to cordova plugins, nor to 'cordova' itself, in this environment. Any news (X3) on fixing this? It has caused headaches for lots of people already (cf. Wizcorp/phonegap-facebook-plugin#866, ionic-team/ng-cordova#446, http://stackoverflow.com/questions/27906239/facebookconnectplugin-is-not-defined-ngcordova-ionic-app, etc.) and fixing it will be critical to maintaining the otherwise high quality of the ionic experience. Thank you. |
any news about it? X4 |
+1 |
2 similar comments
+1 |
+1 |
At this moment we solved this issue by generating a Gulp command that serves the gulp.task('browser:serve', function() {
gulp.src(paths.browser)
.pipe(webserver({
livereload: {enable: true, port: 35729},
directoryListing: false,
host: localhost,
port: 8100,
open: true
}));
}); |
+1 |
2 similar comments
+1 |
+1 |
workaround in #790 |
Having similar problems when using phonegap-facebook-plugin. Would also like to know if possible to resolve this when doing 'ionic serve' |
+1 |
2 similar comments
+1 |
+1 |
+1 |
3 similar comments
+1 |
+1 |
+1 |
+1 |
Throwing another +1 onto the heap |
+1 |
This is really horrible... can you at least throw some log that that's the problem? |
If I do a |
as mark-veenstra already wrote - but let me fix the port from 8100 -> 8000 which is the port the "ionic run browser" works: add this to your gulp file under the other tasks:
|
ionic run browser --live-reload throws |
@lordprettyflacko I get that as well but am able to build and serve for browser (pulling in all js and hooks) with |
@joshuaohana i tried this but my system cant find the http-server command. However it works for me now with ionic serve browser. I dont know why cause i tried so much thing but in the end it works. |
What I have done as a hacky workaround for the time being is just do an ionic build browser and then I copy the
|
By using "ionic run browser --livereload" command I can see the trigger is active: however we need to run a command to compile our changes: cordova prepare browser I hope someone can fix it ASAP. |
+1 Same here |
After inspecting my node_modules/@ionic/app-scripts/dist/serve.js This makes my ionic serve use the browser platform as it's basis and all the good stuff is there provided by serve out of the box (all that I need anyway, didn't check everything). My only issue at present is kind of unrelated, the splash screen plugin requests My logo.png is in the src/assets directory, it would be cool if that got copied over but this may very well be a splash screen plugin issue instead of something to be done on ionic's side. |
At the meantime you can use the following in order to use cordova contacts plugin in ionic serve: |
@petermetz That is a GREAT solution. Working perfectly for me. Thank you! Slight mod - I like having source maps built:
|
@petermetz Epic solution, thank you! To the unrelated issue // <projectRoot>/copy.config.js
const defaultConfig = require('@ionic/app-scripts/config/copy.config');
module.exports = Object.assign({}, defaultConfig, {
copyLogo: {
src: 'platforms/browser/img/logo.png',
dest: '{{WWW}}/img',
},
}); So in your case, you should be able to use If you're not already using an extended config like this, note that you also have to add: // ...
"config": {
"ionic_copy": "copy.config.js"
}
// ... to your |
Thanks for https://github.com/petermetz for providing this workaround in ionic-team/ionic-cli#354!
* ionic start rzp-ionic3-example blank --type=ionic-angular * cordova platform add browser/ios/android && cordova plugin add https://github.com/razorpay/razorpay-cordova.git --save * RZP payment * Use this workaround to load browser plugins ionic-team/ionic-cli#354 (comment) * Define type for RazorpayCheckout * Update Readme
@petermetz your solution won't work when using azure mobile client plugin. anybody has any idea for a workaround? |
…ermetz for providing this workaround in ionic-team/ionic-cli#354!
With ionic 4 this can be done with:
see: #3043 |
Yeah, I think we can close this issue. I think the original request is now fulfilled. #3043 is for a related feature request. |
…ermetz for providing this workaround in ionic-team/ionic-cli#354!
Some (but not all) cordova plugins have Javascript proxies if the features they offer can also be used in a regular browser.
I'm using one such plugin and I need to access the
cordova.plugins.____
object. However, the cordova.js file is a 404 when usingionic serve
. It's not a 404 when usingionic build browser
.How do you access the cordova object in javascript when using ionic serve? Or do you have to
ionic build browser
every single time you want to see your changes?The text was updated successfully, but these errors were encountered: