iOS Notifications push server with php

96 Views Asked by At

I have something wrong with my notifications but i can't see where is the problem. I have an app that generates the token successfully, at first I was able to send a notification from my localhost to the device, but after i restored the device and and tested with the new device token to push a simple notification i couldn't get get it to work even though I didn't made any changes to php code nor my app code, here is my php code :

        require_once 'ApnsPHP/Autoload.php';
        // Instantiate a new ApnsPHP_Push object
        $push = new ApnsPHP_Push(
            ApnsPHP_Abstract::ENVIRONMENT_SANDBOX,
            'server_certificates_bundle_sandbox.pem'
        );

        // Set the Root Certificate Autority to verify the Apple remote peer
        $push->setRootCertificationAuthority('entrust_root_certification_authority.pem');
        // Connect to the Apple Push Notification Service
        $push->connect();

        //  Instantiate a new Message with a single recipient
        $message = new ApnsPHP_Message($token);
        // Set a simple welcome text
        $message->setText("GELLLOOOOOO"); 
        // Play the default sound
        $message->setSound();
        // Add the message to the message queue
        $push->add($message);
        $push->send();
        $push->disconnect();
        // Examine the error message container
        $aErrorQueue = $push->getErrors();
        var_dump($aErrorQueue); 

I think it have something to do with certificates but i'm not sure where is the issues since it was working before and there is nothing in $aErrorQueue , just an empty array.

0

There are 0 best solutions below