1

I built a push notification app with the help of EasyAPNS. Currently I have another app which is a newsstand application. My question is where can I add payload for newsstand notification?

I added something in class_APNS.php like this before I post message:

$usermessage['aps']['content-available'] = 1;   

But my application can never receive the push notification. (I've already registered for the newsstand push notification already.)

Anybody can help? Thanks

Bagusflyer
  • 12,675
  • 21
  • 96
  • 179

1 Answers1

0

I solved the problem.

My method is correct. Let me explain it in more details. I modified queueMessage function inside the class_APNS.php right before the posting. Here is the code:(I added a flag newsstand to indicate it's a newsstand push or a normal push

            if ( $this->newsstand )
            {
                $usermessage['aps']['content-available'] = 1;   
            }
            else {
                if(isset($this->usermessage['aps']['content-available']))
                    unset($this->usermessage['aps']['content-available']);
            }

            $fk_device = $this->db->prepare($deviceid);
            $message = $this->_jsonEncode($usermessage);
            $message = $this->db->prepare($message);
            $delivery = (!empty($when)) ? "'{$when}'":'NOW()';
Bagusflyer
  • 12,675
  • 21
  • 96
  • 179
  • If you do it this way you will be sending content-available with every push message you send. And your app doesn't report if the user enabled newsstand push messages. – Jens Kohl Nov 14 '12 at 10:12
  • No. I only send out content-available when the newsstand is enabled. And this is what I want. The newsstand flag can be set per message. That means even the newsstand application can receive normal push message. – Bagusflyer Nov 27 '12 at 01:28
  • If this is the only change you made to EasyAPNS, where does the client register for newsstand push messages with your callback? – Jens Kohl Nov 27 '12 at 09:16