Push Notification when the userId is not registered at AppHQ yet

0 votes

Hello, I'm using the Push Notification service.

I'm trying to send the push notification to a user whenever another player beat his score. What I'm doing is, player1 register his score and facebook id to mySQL server. Player1 also register facebook id as userId of App42 Push Notification. Then player2 do the same, but with score more than player1. Then the PHP code that manage user score will check that player2's score is more than player1's. So I use this PHP code to send Push Notification to player1

$pushNotification = $pushNotificationService->sendPushMessageToUser($user,$message); 

If player1 has registered his userId with AppHQ, then it's working very fine.

But, in some case including the test, player1 haven't registered to AppHQ just yet (maybe he didn't want to allow push notification). The problem occur here and I got this error :

Fatal error</b>:  Uncaught exception 'com\shephertz\app42\paas\sdk\php\App42NotFoundException' in /home/vhosts/www.kanpot2002.com/1.2/RestClient.class.php:324
Stack trace:
#0 /home/vhosts/www.kanpot2002.com/1.2/PushNotificationService.php(239): com\shephertz\app42\paas\sdk\php\connection\RestClient::post('https://api.she...', Array, NULL, NULL, 'application/jso...', 'application/jso...', '{&quot;app42&quot;:{&quot;push...')
#1 /home/vhosts/www.kanpot2002.com/PushNotificationManager.php(34): com\shephertz\app42\paas\sdk\php\push\PushNotificationService-&gt;sendPushMessageToUser(563043561, 'FIRST_NAME has ...')
#2 /home/vhosts/www.kanpot2002.com/addbestscore.php(85): PushNotificationManager-&gt;SendMessageToUser(563043561, 'FIRST_NAME has ...')
#3 {main}
  thrown in <b>/home/vhosts/www.kanpot2002.com/1.2/RestClient.class.php</b> on line <b>324</b><br />

Then I try using this

try{
$pushNotification = $pushNotificationService->sendPushMessageToUser($user,$message); 
}
catch(Exception $e){}

The result is better. The first user with no userId is catched and has no error. But the second user gave me this error (as if it ignore the try catch statement)

<b>Fatal error</b>:  Call to a member function __get() on a non-object in <b>/home/vhosts/www.kanpot2002.com/1.2/PushNotificationResponseBuilder.php</b> on line <b>23</b><br />
I'm really stucked at this. Please help!
Thanks,
Karnpot
asked Feb 28, 2014 in App42 Cloud API-BaaS by kanpot2002 (10 points)

1 Answer

0 votes

Create a new instance of service when ever you call method of it Like this:

$pushService= $api->buildPushNotificationService();

We will fix this issue in our next release.

 

answered Feb 28, 2014 by sshukla480 (407 points)
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...