Skip to content

Please delete #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 50 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
a86a91f
Reference Cordove 2.2.0 and obscure sender id from example
bobeast Dec 4, 2012
24b0e18
Cleanup documentation and sample layout
bobeast Dec 19, 2012
e25e44d
Cleanup file hierarchy and clarify it in manual installation section …
bobeast Dec 19, 2012
ac095d7
cleanup onLoad functionality
bobeast Jan 17, 2013
cb52942
Update README.md
colene Jan 24, 2013
64204b8
Merge pull request #1 from colene/patch-1
bobeast Jan 24, 2013
e52c125
Add compatibility with 2.3.0
bobeast Feb 2, 2013
1d660fe
Add support for background notifications
bobeast Feb 5, 2013
f854ec2
Add v13 compatibility shim
bobeast Feb 5, 2013
f4703ba
Grab app icon without assuming package name
bobeast Feb 7, 2013
d5f78d0
cleanup construction
bobeast Feb 8, 2013
947468b
Remove old cordova alias
bobeast Feb 9, 2013
b7a2569
Add flag for foreground vs. background for iOS
bobeast Feb 12, 2013
60cb9c7
send entire payload to JS app
bobeast Feb 14, 2013
d61412e
Clean up some unused imports
bobeast Feb 14, 2013
33459fc
Update read me and examples to reflect status bar notifications changes
bobeast Feb 15, 2013
778bbbb
Surface custom key/value pairs to JS for iOS
bobeast Feb 19, 2013
a412c1c
Don't choke if no msgcnt or message values are passed in the notifica…
bobeast Feb 21, 2013
08783e4
Dismiss notification from tray once it has been processed
bobeast Feb 21, 2013
a3dc402
Bump the plugin version
bobeast Feb 21, 2013
2ee858f
Always refresh the content Intent on new notifications.
bobeast Mar 6, 2013
fa8ea29
and bump the version
bobeast Mar 6, 2013
de8c1c5
Remove use of now private uniqueIdentifier accessor
bobeast Mar 22, 2013
86bec0e
bump version for uniqueidentifier fix
bobeast Mar 22, 2013
595e762
Add cold-start functionality
bobeast Mar 26, 2013
a6f665d
Update documentation to reflect new coldstart functionality
bobeast Mar 26, 2013
90fe5b0
Update README.md
markeeftb Mar 27, 2013
43c7d53
Update PushPlugin for 2.5.0+
bobeast Mar 28, 2013
33c34d5
Get rid of deprecated call to getContext()
bobeast Apr 9, 2013
8783b8b
Merge pull request #3 from markeeftb/patch-1
bobeast Apr 15, 2013
bf9e047
Add plugman support
bobeast May 10, 2013
3b24728
Add jasmin test spec
bobeast May 10, 2013
7405313
bump version after adding test spec
bobeast May 10, 2013
9c53a2f
Fix the spec
bobeast May 10, 2013
71cb7f3
fully qualified paths for ios.
filmaj May 16, 2013
b4ff58e
Merge pull request #4 from filmaj/master
bobeast May 16, 2013
30a413b
Updated to Cordova 2.7, fixed a number of bugs. Cleaned up some code.
May 17, 2013
00a8a22
moved libs/gcm.jar to src/android/libs/gcm.jar for plugman compatibility
May 28, 2013
0eab86f
bump version to deliniate 1st Plugman version
bobeast May 30, 2013
2d59987
Remove config file from spec for plugman compatibility
bobeast Jun 4, 2013
720fb77
Accept either Boolean or string argiuments to register method for iOS
bobeast Jun 4, 2013
dd4ca03
Merge pull request #5 from NetMatch/master
bobeast Jun 5, 2013
69fc815
Update documentation for pluginstall
bobeast Jun 5, 2013
06dc8cc
error callback for setApplicationIconBadgeNumber
Jun 6, 2013
437fb4a
Merge pull request #11 from Michael-vb/master
bobeast Jun 6, 2013
8e2c25d
surface payload when app is launched from incoming notification on iOS
bobeast Jun 7, 2013
9baf9f7
Bump version
bobeast Jun 7, 2013
c6ce167
[plugman] renaming GCM/ to gcm/ to make plugman work
Jun 10, 2013
4c53bb3
[1.3.2] upped version
Jun 10, 2013
e7f8c81
Add description tag
bobeast Jun 18, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

.DS_Store
96 changes: 0 additions & 96 deletions Example/index.html

This file was deleted.

8 changes: 0 additions & 8 deletions Example/pushGCM.rb

This file was deleted.

File renamed without changes.
9 changes: 9 additions & 0 deletions Example/server/pushGCM.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require 'rubygems'
require 'pushmeup'
GCM.host = 'https://android.googleapis.com/gcm/send'
GCM.format = :json
GCM.key = "API_KEY_GOES_HERE"
destination = ["REGISTRATION_ID_GOES_HERE"]
data = {:message => "PhoneGap Build rocks!", :msgcnt => "1", :soundname => "beep.wav"}

GCM.send_notification( destination, data)
65 changes: 65 additions & 0 deletions Example/www/PushNotification.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@

var PushNotification = function() {
};


// Call this to register for push notifications. Content of [options] depends on whether we are working with APNS (iOS) or GCM (Android)
PushNotification.prototype.register = function(successCallback, errorCallback, options) {
if (errorCallback == null) { errorCallback = function() {}}

if (typeof errorCallback != "function") {
console.log("PushNotification.register failure: failure parameter not a function");
return;
}

if (typeof successCallback != "function") {
console.log("PushNotification.register failure: success callback parameter must be a function");
return;
}

cordova.exec(successCallback, errorCallback, "PushPlugin", "register", [options]);
};

// Call this to unregister for push notifications
PushNotification.prototype.unregister = function(successCallback, errorCallback) {
if (errorCallback == null) { errorCallback = function() {}}

if (typeof errorCallback != "function") {
console.log("PushNotification.unregister failure: failure parameter not a function");
return;
}

if (typeof successCallback != "function") {
console.log("PushNotification.unregister failure: success callback parameter must be a function");
return;
}

cordova.exec(successCallback, errorCallback, "PushPlugin", "unregister", []);
};


// Call this to set the application icon badge
PushNotification.prototype.setApplicationIconBadgeNumber = function(successCallback, badge) {
if (errorCallback == null) { errorCallback = function() {}}

if (typeof errorCallback != "function") {
console.log("PushNotification.setApplicationIconBadgeNumber failure: failure parameter not a function");
return;
}

if (typeof successCallback != "function") {
console.log("PushNotification.setApplicationIconBadgeNumber failure: success callback parameter must be a function");
return;
}

cordova.exec(successCallback, successCallback, "PushPlugin", "setApplicationIconBadgeNumber", [{badge: badge}]);
};

//-------------------------------------------------------------------

if(!window.plugins) {
window.plugins = {};
}
if (!window.plugins.pushNotification) {
window.plugins.pushNotification = new PushNotification();
}
File renamed without changes.
146 changes: 146 additions & 0 deletions Example/www/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
<!DOCTYPE HTML>
<html>
<head>
<title>com.PhoneGap.c2dm</title>
</head>
<body>

<!--<script type="text/javascript" charset="utf-8" src="cordova-2.2.0.js"></script>-->
<script type="text/javascript" charset="utf-8" src="phonegap.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 onDeviceReady() {
$("#app-status-ul").append('<li>deviceready event received</li>');

document.addEventListener("backbutton", function(e)
{
$("#app-status-ul").append('<li>backbutton event received</li>');

if( $("#home").length > 0)
{
// call this to get a new token each time. don't call it to reuse existing token.
//pushNotification.unregister(successHandler, errorHandler);
e.preventDefault();
navigator.app.exitApp();
}
else
{
navigator.app.backHistory();
}
}, false);

try
{
pushNotification = window.plugins.pushNotification;
if (device.platform == 'android' || device.platform == 'Android') {
$("#app-status-ul").append('<li>registering android</li>');
pushNotification.register(successHandler, errorHandler, {"senderID":"661780372179","ecb":"onNotificationGCM"}); // required!
} else {
$("#app-status-ul").append('<li>registering iOS</li>');
pushNotification.register(tokenHandler, errorHandler, {"badge":"true","sound":"true","alert":"true","ecb":"onNotificationAPN"}); // required!
}
}
catch(err)
{
txt="There was an error on this page.\n\n";
txt+="Error description: " + err.message + "\n\n";
alert(txt);
}
}

// handle APNS notifications for iOS
function onNotificationAPN(e) {
if (e.alert) {
$("#app-status-ul").append('<li>push-notification: ' + e.alert + '</li>');
navigator.notification.alert(e.alert);
}

if (e.sound) {
var snd = new Media(e.sound);
snd.play();
}

if (e.badge) {
pushNotification.setApplicationIconBadgeNumber(successHandler, e.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.
console.log("regID = " + e.regID);
}
break;

case 'message':
// if this flag is set, this notification happened while we were in the foreground.
// you might want to play a sound to get the user's attention, throw up a dialog, etc.
if (e.foreground)
{
$("#app-status-ul").append('<li>--INLINE NOTIFICATION--' + '</li>');

// if the notification contains a soundname, play it.
var my_media = new Media("/android_asset/www/"+e.soundname);
my_media.play();
}
else
{ // otherwise we were launched because the user touched a notification in the notification tray.
if (e.coldstart)
$("#app-status-ul").append('<li>--COLDSTART NOTIFICATION--' + '</li>');
else
$("#app-status-ul").append('<li>--BACKGROUND NOTIFICATION--' + '</li>');
}

$("#app-status-ul").append('<li>MESSAGE -> MSG: ' + e.payload.message + '</li>');
$("#app-status-ul").append('<li>MESSAGE -> MSGCNT: ' + e.payload.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>');
}

document.addEventListener('deviceready', onDeviceReady, true);

</script>
<div id="home">
<div id="app-status-div">
<ul id="app-status-ul">
<li>Cordova PushNotification Plugin Demo</li>
</ul>
</div>
</div>
</body>
</html>
File renamed without changes.
Loading