Hello,

      I am using the PHP API to send push-notifications. Everything worked fine, however when I set the expiry parameter, I'm getting the following error:

   Uncaught Error: Call to undefined function UrbanAirship\Push\expiry() in /home/u/public_html/panel.php Stack trace: #0 {main} thrown in /home/u/public_html/panel.php on line 41

I'll share a snippet of the code where the error occurs:

try {
    $response = $airship->push()
        ->setAudience(P\all)
        ->setNotification(P\notification($content))
        ->setOptions(P\expiry(10800))
        ->setDeviceTypes(P\all)
        ->send();
} catch (AirshipException $e) {
    print_r($e);
}

How do I resolve this error?

 

-Thanks

Didn't find what you were looking for?

New post

Comments

1 comment

  • Hi Abhishek,

    The reason you are receiving that error is because expiry() isn't a function in the PHP library. At this time you cannot set universal expiry in the PHP library, but you can set expiry on the iOS and Android platform overrides:


    $response = $airship->push()
        ->setAudience(P\all)
        ->setNotification(P\notification(
            null,
            array("ios"=>P\ios(
                "Hello iOS",
                null,
                null,
                false,
                null,
                10800
            )),
            array("android"=>P\android(
                "Hello Android",
                null,
                10800
            ))
        ))
        ->setDeviceTypes(P\deviceTypes('ios', 'android'))
        ->send();

    This should ensure the notifications expire three hours after being sent. Please let me know if you have any other questions or concerns.

    Best regards,
    Jenn

    0

Please sign in to leave a comment.