Toggle Button to On/OFF on Condition

Hello All,

I have used ion toggle with ng-model=“listItem.checked ng-change=notifyUser(listItem)” ng-checked=“listItem.checked”. Let us assume this is a button to switch off ignition of a car through SMS.

The toggle off sends stop message and toggle on sends start message. On clicking toggle button SMS must be sent and after success callback (of SMS) toggle animation must happen and change the state else if it goes to error callback the animation should not change.

Is it possible ?