I am trying to use the native Toast, but I always got “toast error: undefined”
Here is the code:
Toast.show('Hello there!', 'long', 'center').subscribe(
a => {
console.log('toast success: '+ a)
},
b => {
alert('toast error: ' + b)
}
);
I am using BB10, but I know the “cordova-plugin-x-toast” should work with that OS. Any idea? Do you think it is because the plugin is not loaded properly? Do I need to add a “this._platform.ready().then”?
Just got an old Android phone. I will try to run on that device (Samsung S4).
By the way, any advice how to setup an Ionic 2 project to run on an Android device and emulator?
I installed the SDK, put my phone on developer mode, I tried ionic emulate android and ionic run android. It built, installed and launched on the emulator, but got this error:
I thought the ‘run’ will start the app on the phone, but maybe it is doing something else?
Thanks in advance
[UPDATE]: when sending the question about the issue, I got it work on the phone! The simulator still has the issue, but that’s ok. I prefer to work on a real device!
@mhartington
Thanks Mike. But it is not solved my problem with incorrect plugin installation.
Maybe there is way to get some additional info from ionic-native to find the cause?
Or maybe I should reinstall the plugin by removing it with cordova plugin remove ... and then reinstall it with ionic plugin add cordova-plugin-x-toast ?
What would you recommend to do in such a case?
I really don’t want to refactoring the whole working project to make toasts work.
And earning some basic “plugin debugging” skills will be very nice.
To run on the Android emulator you use the following command:
ionic emulate android -l -c
-l will give you livereload
-c will give console log to the terminal
I’m also finding Toasts don’t work when using ionic-native, but if I use them directly they work with one issue, on an actual device I get the Cordova icon at the top left corner of the toast and don’t know how to get rid of it.
Interesting, so the ionic-native version only works with the .subscribe tacked on.
Does anybody know why I’m getting the Cordova icon on my Toasts? It only appears on my Android device, not in the emulator. Better yet, does anybody know how to get rid of it?
Finally found out what’s going on, it’s a ‘feature’ of Cyanogenmod ROM. So no longer need to worry about it, typical users will never see it, and those that have Cyanogen installed, nothing we can do about it.
Apparently the idea behind it is because it’s a platform feature any app could be causing the Toast, it’s so the user knows which app is responsible.