Can't use promise on android? What's going on here!


#1

I was in the middle of moving my Image cropper over to using promises when a wild bug appeared. (Note: Have not tested on iOS yet) and this works perfectly fine in the emulator for android and iOS devices.

function example() {
    alert('Example called');
    return new Promise(function(resolve, reject) {
	alert('Promise created');
	resolve({});
    });
}

Calling example on the emulator will yield expected results, while compiling on running on a mobile device yields only the “Example called” alert. Is this a bug or expected behavior?


#2

Can you use $q.defer().promise instead? That’s the provided AngularJS implementation. What could be happening is the Android browser doesn’t support the promise API. Also I recommend you install Crosswalk.

http://blog.ionic.io/crosswalk-comes-to-ionic/