Hi,
I tried to send push from php to android device, the push works if i use the appHQ console
but it doesn't work when i use PHP to send. The metering at appHQ shows that there's operation going through, but not at the push log.
i try to catch the exception, but nothing seems to be wrong.
i got the device token from the log when i registering the device, and the username as well
below is the php code i used
try {
$pushNotificationService = App42API::buildPushNotificationService();
$pushNotification = $pushNotificationService->sendPushMessageToDevice($userName, $deviceToken, $message);
print_r("Message is :" . $pushNotification->getMessage());
print_r("Expiry is :" . $pushNotification->getExpiry());
print_r("UserName is :" . $pushNotification->getUserName());
$jsonResponse = $pushNotification->toString();
} catch (App42Exception $exception) {
$appErrorCode = $exception->getAppErrorCode();
$httpErrorCode = $exception->getHttpErrorCode();
if ($appErrorCode == 1709) {
echo "User by the name '@userName' device token '@deviceToken' does not registered.";
} else if ($appErrorCode == 1401) {
// handle here for Client is not authorized
} else if ($appErrorCode == 1500) {
// handle here for Internal Server Error
}
$jsonText = $exception->getMessage();
echo $jsonText;
}