-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Allow unique notification icons for separate notifications #6
Open
anyandallart
wants to merge
135
commits into
bobeast:master
Choose a base branch
from
anyandallart:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
Fix apple link.
Update README.md
You need to add android.permission.GET_TASKS. Without this permission, the application crashes when it receives PUSH NOTIFICATION.
Update README.md
Allow the plugin to know when the app is no longer in foreground so that it may receive push notifications
#85 No notifications in android when the app is closed
We can rely on the the other activity functions setting foreground to be true
We should always send a notification this is better than never sending one
#85 - new approach
adds android.permission.VIBRATE needed for android 2.3.x
Update plugin.xml
json key should be surrounded by quotation
fix e.regid in README
Fixed quotes unescaping for non string values
Added instrucction to Android manual installation
Update README.md
**NOTE: For this to work you must also modify PushHandlerActivity.java as indicated in this fork. Modeled after Facebook / Google Hangouts ability for each notification to have a different icon depending on the message (i.e. if you get a message from Jan, Jan's picture shows up as the notification icon, if you get a message from Bill, Bill's picture shows up as the notification icon, etc.). Just pass the url of the image you want to show up for that particular notification as the variable "icon" in your GCM request. Works like this in the GCM request: (modeled after http://stackoverflow.com/questions/11242743/gcm-with-php-google-cloud-messaging) <?php // Replace with real BROWSER API key from Google APIs $apiKey = "asAdds235fsdfsdf2342aEl3432534634BNgg"; // Replace with real client registration IDs. Put the correct registration id you are getting from app. If you are using eclipse check your logcat you will get it there. $registrationIDs = array( "APA91bHpXL6QHMUMVjR1WB3sNTwCEj243434342525345LXAR2Mwp6KJKmTTp9hqE-b57683424233YjMJH5vZIEtbNbyUWOVQhS5gFEjJQLYs5pvEdqpPkHn9VeFp1A" ); /* Message to be sent - Make sure that message is the key you are using in GCMIntentService.java onMessage() -> extras.getString("message"); */ $message = "Life is incredibly exciting ...."; $title="You have a message."; // Set POST variables. $url = 'https://android.googleapis.com/gcm/send'; $icon='http://www.example.com/BillsProfilePicture.jpg'; $fields = array( 'registration_ids' => $registrationIDs, 'data' => array( "message" => $message, "title" => $title, "notId"=>'300', "icon"=>$icon ) ); $headers = array( 'Authorization: key=' . $apiKey, 'Content-Type: application/json' ); // Open connection $ch = curl_init(); // Set the url, number of POST vars, POST data curl_setopt( $ch, CURLOPT_URL, $url ); curl_setopt( $ch, CURLOPT_POST, true ); curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode( $fields ) ); // Execute post $result = curl_exec($ch); // Close connection curl_close($ch); // Echo success or failure echo $result; ?> ********************** Also, FYI, I merged the code from TheNewMR from here to allow for stacked notifications depending on different notification ID's: thenewmr@728e975 Instructions for how that works are on that page, however in case it gets deleted for some reason I'll copy/paste here: "This allows for multiple notifications to be displayed on Android. Simply add data with key "notId" and an integer value when sending via GCM. Differentiate between different notifications by setting different notIds. Defaults to 0 if not key supplied."
Just send a push with the GCM variable cancelNotification set (can be set to anything) and the notification will be dismissed. Default functionality uses the standard NOTIFICATION_ID=237. The code addition also works with the the code from TheNewMR (thenewmr@728e975) which allows for stacked notifications depending on different notification ID's. To dismiss a Notification ID just make sure to set the GCM variable cancelNotification and to set notId to the notification ID you want to dismiss.
Just send a push with the GCM variable cancelNotification set (can be set to anything) and the notification will be dismissed. Default functionality uses the standard NOTIFICATION_ID=237. The code addition also works with the the code from TheNewMR (thenewmr/PushPlugin@728e975) which allows for stacked notifications depending on different notification ID's. To dismiss a Notification ID just make sure to set the GCM variable cancelNotification and to set notId to the notification ID you want to dismiss.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Modeled after Facebook / Google Hangouts ability for each notification to have a different icon depending on the message (i.e. if you get a message from Jan, Jan's picture shows up as the notification icon, if you get a message from Bill, Bill's picture shows up as the notification icon, etc.).
Just pass the url of the image you want to show up for that particular notification as the variable "icon" in your GCM request. Works like this in the GCM request:
extras.getString("message"); */ $message = "Life is incredibly exciting ...."; $title="You have a message."; // Set POST variables. $url = 'https://android.googleapis.com/gcm/send'; $icon='http://www.example.com/BillsProfilePicture.jpg'; $fields = array( 'registration_ids' => $registrationIDs, 'data' => array( "message" => $message, "title" => $title, "notId"=>'300', "icon"=>$icon ) ); $headers = array( 'Authorization: key=' . $apiKey, 'Content-Type: application/json' ); // Open connection $ch = curl_init(); // Set the url, number of POST vars, POST data curl_setopt( $ch, CURLOPT_URL, $url ); curl_setopt( $ch, CURLOPT_POST, true ); curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode( $fields ) ); // Execute post $result = curl_exec($ch); // Close connection curl_close($ch); // Echo success or failure echo $result; ?>(modeled after http://stackoverflow.com/questions/11242743/gcm-with-php-google-cloud-messaging)
Also, FYI, I merged the code from TheNewMR from here to allow for stacked notifications depending on different notification ID's:
thenewmr@728e975
Instructions for how that works are on that page, however in case it gets deleted for some reason I'll copy/paste here:
"This allows for multiple notifications to be displayed on Android. Simply add data with key "notId" and an integer value when sending via GCM. Differentiate between different notifications by setting different notIds. Defaults to 0 if not key supplied."