Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ryanpager/81252906efe435734c58 to your computer and use it in GitHub Desktop.
Save ryanpager/81252906efe435734c58 to your computer and use it in GitHub Desktop.
Cordova Socket Notifications Example
###
Setup
###
# ...in the app.config
SocketProvider.setLocation url
# ... in the app.boostrap
Socket.connect()
Socket.listen()
###
Socket Service Class
... assumes that we have a socket connection already
###
socket.listen = ->
$cordovaBackground.enable()
###
Receive all events from the socket, and using the data, display a local notification (same as push).
Because the app is now running in the background, any received and displayed local notification will light up the phone.
...boom.
###
socket.on 'receive', (e, data) =>
$cordovaLocalNotification.display(...put your display params here)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment