1

我正在使用 Shephertz 的 App42 的推送通知服务。

每当另一个玩家击败他的分数时,我都会尝试向用户发送推送通知。我正在做的是,player1 将他的分数和 facebook id 注册到 mySQL 服务器。Player1 还将 facebook id 注册为 App42 Push Notification 的 userId。然后 player2 做同样的事情,但得分高于 player1。然后管理用户分数的 PHP 代码将检查 player2 的分数是否高于 player1 的分数。所以我使用这个 PHP 代码向 player1 发送推送通知

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

如果 player1 已经在 AppHQ 注册了他的 userId,那么它工作得很好。

但是,在某些情况下,包括测试,player1 还没有注册到 AppHQ(也许他不想允许推送通知)。问题发生在这里,我得到了这个错误:

致命错误:/home/vhosts/www.kanpot2002.com/1.2/RestClient.class.php:324 中未捕获的异常 'com\shephertz\app42\paas\sdk\php\App42NotFoundException' 堆栈跟踪:

#0 /home/vhosts/www.kanpot2002.com/1.2/PushNotificationService.php(239): com\shephertz\app42\paas\sdk\php\connection\RestClient::post(' https://api.she . ..', 数组, NULL, NULL, 'application/jso...', 'application/jso...', '{"app42":{"push...')

#1 /home/vhosts/www.kanpot2002.com/PushNotificationManager.php(34): com\shephertz\app42\paas\sdk\php\push\PushNotificationService->sendPushMessageToUser(563043561, 'FIRST_NAME has ...')

#2 /home/vhosts/www.kanpot2002.com/addbestscore.php(85): PushNotificationManager->SendMessageToUser(563043561, 'FIRST_NAME has ...')

#3 {main}在第324行的/home/vhosts/www.kanpot2002.com/1.2/RestClient.class.php中抛出

然后我尝试使用这个

尝试{ $pushNotification = $pushNotificationService->sendPushMessageToUser($user,$message); } 捕捉(异常 $e){}

结果更好。第一个没有 userId 的用户被捕获并且没有错误。但是第二个用户给了我这个错误(好像它忽略了 try catch 语句)

致命错误:在第23 行的/home/vhosts/www.kanpot2002.com/1.2/PushNotificationResponseBuilder.php中的非对象上调用成员函数 __get()

我真的被困在这一点上。请帮忙!

谢谢,

看点2002

4

1 回答 1

2

每当你调用它的方法时创建一个新的服务实例像这样:

$pushService= $api->buildPushNotificationService();
于 2014-03-03T06:20:37.160 回答