Update functions.js

Fixed some errors. Fixed notification errors on iOS preventing the server operations from working properly.