Skip to content

Allow unique notification icons for separate notifications #6

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

Open
wants to merge 135 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
135 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
b51d164
made code more readable and better :-)
Jul 7, 2013
3a5229e
[plugin.xml] add license tag
goya Jul 9, 2013
ed96570
Update plugin.xml
jdhiro Jul 23, 2013
2d17b4a
Clean up and formatting
jdhiro Jul 23, 2013
739476f
Updating java imports to work with the new Cordova 3.0 API
jdhiro Jul 23, 2013
fe01c16
Updating iOS PushPlugin for ARC builds (cordova-cli 3.0 default confi…
jdhiro Jul 23, 2013
a359fa5
Getting the plugin to register on iOS in a Cordova 3.0 environment
jdhiro Jul 24, 2013
b5640c6
Fix typo: successCallback should be errorCallback
rjmunro Aug 23, 2013
669c15f
Restrict current version of plugin to PG < 3.0
bobeast Sep 9, 2013
d91f7a2
remove trailing tab
bobeast Sep 9, 2013
dc03338
Add author element
bobeast Sep 9, 2013
1660c4e
Escape < and > in engines element
bobeast Sep 9, 2013
9beb8b2
Use canonical namespace prefix for plugin id
bobeast Sep 9, 2013
4dd9684
Make fuzzy version matching a little less fuzzy
bobeast Sep 9, 2013
ad19c70
Bump version to 1.3.5
bobeast Sep 9, 2013
99050b9
Try with explicit version matching
bobeast Sep 10, 2013
8b23e04
bump version
bobeast Sep 10, 2013
406d138
Return of fuzzy version matching
bobeast Sep 10, 2013
7a5d5fb
Update the readme with new domain prefix and correct plugman instruct…
bobeast Sep 10, 2013
9036ea0
Merge pull request #61 from phonegap-build/bobeast-fixes
bobeast Sep 10, 2013
20bbc66
add support for 3.0.0
bobeast Sep 10, 2013
1247986
Merge pull request #49 from rjmunro/patch-1
bobeast Sep 10, 2013
6ffb58b
Merge pull request #32 from florianbachmann/master
bobeast Sep 10, 2013
91e7878
Bump version after some miner pull requests
bobeast Sep 10, 2013
9f6465d
Eliminate need for GET_TASKS permission
rjmunro Sep 10, 2013
9a89ce8
added a missing comma after errorHanlder
smorstabilini Sep 13, 2013
d2680f1
Merge pull request #65 from smorstabilini/master
bobeast Sep 13, 2013
3a40075
Fixes Cordova error when trying to open the app from the notification…
Sep 24, 2013
82606ac
Sets default notification sound, vibration and lights and removes use…
Sep 24, 2013
585a84c
Merge pull request #69 from rubennorte/master
bobeast Sep 26, 2013
91863c2
Merge pull request #64 from rjmunro/feature/eliminate-get-tasks
bobeast Sep 26, 2013
a7a47ee
enable syntax highlighting for code examples
armno Sep 26, 2013
a5ddf01
use tabs instead of spaces for indentation (to be consistent)
armno Sep 26, 2013
9a745a6
Added getString method to setContentTitle and setTicker
madebycm Oct 1, 2013
860bca6
added foreground boolean
edewit Oct 4, 2013
a5aa12d
initially app is in foreground
edewit Oct 4, 2013
f0b6612
do not add notification if application in foreground
edewit Oct 4, 2013
3b7e924
Don't use two different bundle ids
bobeast Oct 4, 2013
1bbc0a2
Death of a bad idea
bobeast Oct 4, 2013
39c9871
Merge pull request #71 from armno/readme-syntax-highlighting
bobeast Oct 4, 2013
3cff2aa
Merge pull request #76 from madebycm/master
bobeast Oct 4, 2013
486c877
Merge pull request #80 from edewit/foreground
bobeast Oct 4, 2013
8c8db7b
Fix Application badge number issue for >3.0
bobeast Oct 4, 2013
22ad59f
getString should be extras.getString
Oct 7, 2013
b411a38
Merge pull request #83 from igama/master
bobeast Oct 7, 2013
c5dfcb1
Added clobbers
mkuklis Oct 12, 2013
9852a6c
Added PushNotification to module.exports.
mkuklis Oct 12, 2013
2c20456
Fixed clobbers
mkuklis Oct 12, 2013
80735f0
Encapsulating strings in single quotes is not valid JSON. Change to d…
chriswiggins Oct 16, 2013
89477f1
Remove trailing comma for foreground flag and convert to double quotes
chriswiggins Oct 16, 2013
504a8b4
call callbacks
edewit Oct 25, 2013
0720ade
Merge branch 'master' of github.com:phonegap-build/PushPlugin into ca…
edewit Oct 25, 2013
2257ae8
Merge pull request #98 from edewit/callback
bobeast Oct 28, 2013
a22911d
Merge pull request #91 from chriswiggins/json_fix
bobeast Oct 28, 2013
23a130b
Merge pull request #87 from mkuklis/master
bobeast Oct 28, 2013
09570c4
#85 No notifications in android when the app is closed
Oct 31, 2013
8590b64
Merge pull request #99 from scotthooker/master
bobeast Oct 31, 2013
8d91c7d
bump version for cold-start notification fix
bobeast Oct 31, 2013
069c728
Initially the app is not inforeground
Oct 31, 2013
a6d9668
remove changes
Nov 1, 2013
fb22a69
this is the best case
Nov 1, 2013
a0f2427
Merge pull request #102 from scotthooker/master
bobeast Nov 2, 2013
5bc371c
Make notifications more consistent when not in the foreground
bobeast Nov 2, 2013
158f755
json key should be surrounded by quotation
Nov 13, 2013
4a50133
Update plugin.xml
cuatl Nov 13, 2013
258e32a
Merge pull request #114 from cuatl/master
bobeast Nov 13, 2013
cd8bae9
escape newlines, double-quotes and back-slashes of push message
Nov 19, 2013
0eabba5
On Android, don't post notification twice if in the foreground
bobeast Nov 23, 2013
2a36eaa
Merge pull request #111 from ma2/master
bobeast Nov 23, 2013
b0c0327
Capitalization error in example
bobeast Nov 23, 2013
361e957
fix e.regid in README
cuatl Nov 23, 2013
8f11b31
Update README.md
keab42 Nov 25, 2013
e71da3d
Fixed quoute unescaping for non string values
fesor Nov 30, 2013
e42c659
Added instrucction to Android manual installation
sebastiansier Dec 1, 2013
bad78b8
Merge pull request #122 from cuatl/master
bobeast Dec 3, 2013
4487e9e
Merge pull request #129 from fesor/master
bobeast Dec 3, 2013
0b4aa1d
Merge pull request #130 from sebastiansier/android_installation
bobeast Dec 3, 2013
cf88ef4
Fix some assumptions about payload content.
bobeast Dec 3, 2013
93067b9
Merge pull request #124 from keab42/patch-1
bobeast Dec 3, 2013
dc9d495
shutdown cleanup
bobeast Dec 9, 2013
e5ecdc6
Added WP8 support
EddyVerbruggen Mar 14, 2014
42be9a1
Allow unique icons for each separate notification
anyandallart Mar 23, 2014
21122d0
Update PushHandlerActivity.java
anyandallart Mar 23, 2014
85e9dc9
Added ability to dismiss notifications remotely
anyandallart Mar 23, 2014
cf2c01b
Dismiss notifications remotely (v2)
anyandallart Mar 23, 2014
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.iml
.idea
.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