I kept getting error messages ("Failed to install 'cordova-plugin-whitelist':CordovaError: Plugin doesn't support this project's cordova-ios version. cordova-ios: 3.9.1, failed version requirement: >=4.0.0-dev", and "Failed to install 'cordova-plugin-service-worker':Error: Expected plugin to have ID "com.vladstirbu.cordova.promise" but got "es6-promise-plugin".") when I tried to run the sample app.
I kept getting error messages ("Failed to install 'cordova-plugin-whitelist':CordovaError: Plugin doesn't support this project's cordova-ios version. cordova-ios: 3.9.1, failed version requirement: >=4.0.0-dev", and "Failed to install 'cordova-plugin-service-worker':Error: Expected plugin to have ID "com.vladstirbu.cordova.promise" but got "es6-promise-plugin".") when I tried to run the sample app.
Further information on those error messages can be found at http://stackoverflow.com/questions/30991828/cordova-plugin-whitelist-failed-asking-for-cordova-ios-4?lq=1 and https://github.com/MobileChromeApps/cordova-plugin-service-worker/issues/14.
The following sequence of commands got it to work.
cordova create BackgroundSyncDemo io.cordova.backgroundsyncdemo BackgroundSyncDemo cd BackgroundSyncDemo cordova platform add ios cordova plugin add cordova-plugin-whitelist@1.0.0 cordova plugin add https://github.com/MobileChromeApps/cordova-plugin-service-worker cordova plugin add cordova-plugin-service-worker-background-sync mv 'plugins/cordova-plugin-service-worker-background-sync/sample/config.xml' 'config.xml' mv 'plugins/cordova-plugin-service-worker-background-sync/sample/www/sw.js' 'www/sw.js' mv 'plugins/cordova-plugin-service-worker-background-sync/sample/www/index.html' 'www/index.html' mv 'plugins/cordova-plugin-service-worker-background-sync/sample/www/js/index.js' 'www/js/index.js' mv 'plugins/cordova-plugin-service-worker-background-sync/sample/www/css/index.css' 'www/css/index.css' cordova prepare