0
votes

I installed the x-toaster plugin in my ionic2 project with:

cordova plugin add cordova-plugin-x-toast --save

In Code I try:

window['plugins'].toast.show(message, "short", position);

Above does not seem to get hold of the plugin.

enter image description here

My Component:

 constructor(
        public  navController:  NavController,
        private formBuilder:    FormBuilder,
        private goalService:    GoalService,
        private authService:    AuthService,
        private navService:     NavService,
        public platform:        Platform
    ) {
        super()
        this.contractForm = formBuilder.group({
            termsAccepted: [false, Validators.required],
        })
    }

     showToast(message, position) {
        this.platform.ready().then(() => {
            window['plugins'].toast.show(message, "short", position);
        });
    }
2
Define "nothing of the above is working". What isn't working? Any error message? What have you tried so far? - grooveplex
See updated screenshot - Steve K
Do I need to import or inject that cordova plugins somehow? - Steve K
see below answer, yet it does show the toaster. but.. no more console errors.. - Steve K

2 Answers

0
votes
import { Toast } from 'ionic-native'

then in code do Toast.

.. however it is still not showing, fortunately all console errors are gone. Any ideas are welcome.

0
votes

You have 2 options:

1)

import . . .
import . . .
declare var cordova;
. 
.
.
cordova.plugins.toast.show(message, "short", position);

2)

(<any>window).plugins.toast.show(message, "short", position);