0

I have a PHP code for sending pushNotifications to registered mobiles. The notification includes fields of database like "Collection Title", "Community" and a "Collection handle (unique ID)". After the message is received on mobile, when the user clicks on that message, I want a webview of that particular collection handle in android app.

I have searched through various posts, however I am unable to get the desired code. Any help in this regard would be highly appreciated.

Excerpts of "sendnotification.php" file

$sql1 = "SELECT community.name as inst, collection.name as coll,
handle.handle as handle FROM community2collection, collection2item, handle,   community, collection WHERE community2collection.collection_id = collection2item.collection_id AND community.community_id = community2collection.community_id AND collection.collection_id = collection2item.collection_id AND collection2item.item_id = handle.resource_id 
ORDER BY handle.handle_id desc limit 2";

$result1 = pg_exec($cnn, $sql1);
$numrows1 = pg_numrows($result1);
echo "numrows1=" . $numrows1;


for($ri = 0; $ri < $numrows1; $ri++) {

    $row = pg_fetch_array($result1, $ri);
    echo "row=" . $ri;

$pushMessage = $row[1]. " submitted by " .$row[0];
    if(isset($gcmRegIds) && isset($pushMessage)) {
        $message = array('message' => $pushMessage);
        echo $pushMessage;
        $pushStatus = sendPushNotification($gcmRegIds, $message);
        echo $pushStatus;
        echo "row2field=" .$row[2];

Here I want to create the URL dynamically for specific handle in the notification in android app i.e. based on field $row(2) in the code above. I am using GCM service for sending notifications.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
  • When notification clicked, your mainactivity opens. You just need to pass $row(2) as bundle value and base on that value start your desire activity. – Divyesh Patel Nov 06 '16 at 05:35
  • Thanks Divyesh for the answer. I got some sample code here too http://stackoverflow.com/questions/768969/passing-a-bundle-on-startactivity. – Himanshu Nov 11 '16 at 11:45
  • But I am afraid the row(2) field is not available in the notification. Is there a way to retrieve the row(2) field in the android application from the database/ webserver.? – Himanshu Nov 28 '16 at 08:44
  • please describe more. I don't understand what u really want. – Divyesh Patel Nov 28 '16 at 09:29
  • I understand what u want. You need to pass that $row2 value in notification intent putextra value. And when user click on message your default activity open. In that activity, in oncreate() method check for bundle value if it matches your criteria then open webview activity. – Divyesh Patel Nov 29 '16 at 04:27

0 Answers0