Created
August 13, 2015 14:46
-
-
Save ryanpager/81252906efe435734c58 to your computer and use it in GitHub Desktop.
Cordova Socket Notifications Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
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