backgroundMode plugin works only half-way in iOS


#1

Quick Disclaimer:
This plug in does wonders for me on the Android side!
AND My concern is applicable only to the iOS side.

I posted my code sample at the very end of this writing: There I have, a function called ( Vibrate ) which is set to run every other 10 sec. I know it is running because of the vibrations. And so long as you keep the app in the foreground, everything is fine.

The problem is when I switch to a different app, (or go to the home screen or turn off the screen), I get ONLY ONE MORE VIBRATION. And That’s it. After that one last final one coming from the background, I get no more vibrations.

Interestingly, as soon as the app comes to the foreground thoug, it starts with an instant vibration ( as if something was holding it ) and after that instant one, it continues to do the regular vibrations that is every other 10 seconds.

I tested this line:

window.cordova.plugins.backgroundMode.enable();

It seems to be doing something! ( Because when I comment that one-liner, that ONE-MORE-VIBRATION no longer happens. And we hear nothing from the backgrounded app. This is to prove that that one-liner does have some meaning to iOS. )

I’m not sure what I am missing here that this plugin misses its main point in the iOS but yet the same code works perfect for the android?

Here is my code sample:

app.run(function($cordovaVibration, $cordovaMedia, $cordovaGeolocation, $ionicPlatform, $cordovaSplashscreen) {
  $ionicPlatform.ready(function() {
    if(window.cordova && window.cordova.plugins.Keyboard) {
        cordova.plugins.Keyboard.hideKeyboardAccessoryBar(false);
        cordova.plugins.Keyboard.disableScroll(true);
        // Enable background mode
        window.cordova.plugins.backgroundMode.enable();
        var interval = setInterval(function () {
          Vibrate();
        },10*1000);
    } else {
        isDevice = false;
    }
  });
})