This repository has been archived by the owner on Sep 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
2,029 additions
and
3 deletions.
There are no files selected for viewing
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<head> | ||
<title>com.PhoneGap.c2dm</title> | ||
<script type="text/javascript" charset="utf-8" src="cordova-2.1.0.js"></script> | ||
<script type="text/javascript" charset="utf-8" src="jquery_1.5.2.min.js"></script> | ||
<script type="text/javascript" src="PushNotification.js"></script> | ||
|
||
<script type="text/javascript"> | ||
var pushNotification; | ||
|
||
function onLoad() { | ||
document.addEventListener('deviceready', onDeviceReady, true); | ||
} | ||
|
||
function onDeviceReady() { | ||
$("#app-status-ul").append('<li>deviceready event received</li>'); | ||
|
||
pushNotification = window.plugins.pushNotification; | ||
if (device.platform == 'android' || device.platform == 'Android') { | ||
pushNotification.register(successHandler, errorHandler, {"senderID":"661780372179","ecb":"onNotificationGCM"}); | ||
} else { | ||
pushNotification.register(tokenHandler, errorHandler, {"badge":"true","sound":"true","alert":"true","ecb":"onNotificationAPN"}); | ||
} | ||
} | ||
|
||
// handle APNS notifications for iOS | ||
function onNotificationAPN(event) { | ||
if (event.alert) { | ||
$("#app-status-ul").append('<li>push-notification: ' + event.alert + '</li>'); | ||
navigator.notification.alert(event.alert); | ||
} | ||
|
||
if (event.sound) { | ||
var snd = new Media(event.sound); | ||
snd.play(); | ||
} | ||
|
||
if (event.badge) { | ||
pushNotification.setApplicationIconBadgeNumber(successHandler, event.badge); | ||
} | ||
} | ||
|
||
// handle GCM notifications for Android | ||
function onNotificationGCM(e) { | ||
$("#app-status-ul").append('<li>EVENT -> RECEIVED:' + e.event + '</li>'); | ||
|
||
switch( e.event ) | ||
{ | ||
case 'registered': | ||
if ( e.regid.length > 0 ) | ||
{ | ||
$("#app-status-ul").append('<li>REGISTERED -> REGID:' + e.regid + "</li>"); | ||
// Your GCM push server needs to know the regID before it can push to this device | ||
// here is where you might want to send it the regID for later use. | ||
} | ||
break; | ||
|
||
case 'message': | ||
$("#app-status-ul").append('<li>MESSAGE -> MSG: ' + e.message + '</li>'); | ||
$("#app-status-ul").append('<li>MESSAGE -> MSGCNT: ' + e.msgcnt + '</li>'); | ||
break; | ||
|
||
case 'error': | ||
$("#app-status-ul").append('<li>ERROR -> MSG:' + e.msg + '</li>'); | ||
break; | ||
|
||
default: | ||
$("#app-status-ul").append('<li>EVENT -> Unknown, an event was received and we do not know what it is</li>'); | ||
break; | ||
} | ||
} | ||
|
||
function tokenHandler (result) { | ||
$("#app-status-ul").append('<li>token: '+ result +'</li>'); | ||
// Your iOS push server needs to know the token before it can push to this device | ||
// here is where you might want to send it the token for later use. | ||
} | ||
|
||
function successHandler (result) { | ||
$("#app-status-ul").append('<li>success:'+ result +'</li>'); | ||
} | ||
|
||
function errorHandler (error) { | ||
$("#app-status-ul").append('<li>error:'+ error +'</li>'); | ||
} | ||
</script> | ||
</head> | ||
<body onload="onLoad();"> | ||
<div id="app-status-div"> | ||
<ul id="app-status-ul"> | ||
<li>Cordova Google Cloud Messaging Plugin Demo</li> | ||
</ul> | ||
</div> | ||
</body> | ||
</html> |
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
require 'rubygems' | ||
require 'pushmeup' | ||
|
||
|
||
APNS.host = 'gateway.sandbox.push.apple.com' | ||
APNS.port = 2195 | ||
APNS.pem = '</path/to/my/certificate/ck.pem>' | ||
APNS.pass = '<myCertificatePassword>' | ||
|
||
device_token = '<device token gleaned from xcode console>' | ||
# APNS.send_notification(device_token, 'Hello iPhone!' ) | ||
APNS.send_notification(device_token, :alert => 'PushPlugin works!!', :badge => 1, :sound => 'beep.wav') |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require 'rubygems' | ||
require 'pushmeup' | ||
GCM.host = 'https://android.googleapis.com/gcm/send' | ||
GCM.format = :json | ||
GCM.key = "AIzaSyB9bWG4OL5-m0eSE5PYaOhsE4lvKwpWBeg" | ||
destination = ["APA91bHi2_juaN9NMBn8bh2rzC-VTg47E8DckJzxVyVr8zxOHI-IswZZibeyyNQo6Wj9u7XVHs_eizoILByPODGtYo71O0qjGaqOoloq6fRBc8DyhQCR1KmZY6qOlUJAKqE21pD5VGN9"] | ||
data = {:message => "this is a test", :msgcnt => "1"} | ||
GCM.send_notification( destination, data) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Copyright 2012 Bob Easterday, Adobe Systems | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
Oops, something went wrong.