Git Product home page Git Product logo

Comments (15)

dantaylorseo avatar dantaylorseo commented on August 25, 2024 1

@Edujugon sir aim getting this error please help exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Class 'Edujugon\PushNotification\PushNotification' not found' in

Use use Edujugon\PushNotification\PushNotification; at the top of your file

from pushnotification.

Edujugon avatar Edujugon commented on August 25, 2024

Hello,
Notice that the showed code is not using the facade so kindly confirm your use statement at the head of your class is something like this:

use Edujugon\PushNotification\PushNotification;

And no like this:

use Edujugon\PushNotification\Facades\PushNotification;

from pushnotification.

dantaylorseo avatar dantaylorseo commented on August 25, 2024

Perfect thanks for that.

Now onto the last part... I get

stdClass Object ( [success] => 1 [failure] => 2 [tokenFailList] => Array ( [0] => deviceToken2 [1] => deviceToken3 ) )

I added the default device tokens to test errors

So it looks like it's completing but no pushes are received. I have tried in dry run and prod.

I am getting the deviceToken via:

func application(_ application: UIApplication,
            didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {

        var token: String = ""
        for i in 0..<deviceToken.count {
            token += String(format: "%02.2hhx", deviceToken[i] as CVarArg)
        }

        print("tokenString: \(token)")

    }

from pushnotification.

Edujugon avatar Edujugon commented on August 25, 2024

@dantaylorseo
After checking your details, I suggest you to check on the mobile app side. As you can see in the push service response, it shows 1 success which that token is the one you create. So the token is correct and for the push service provider the notification has been sent.

Maybe the app is not getting the notifications as expected. Did you check that yet?

from pushnotification.

dantaylorseo avatar dantaylorseo commented on August 25, 2024

@Edujugon If I use PushMeBaby to test the deviceToken I get the notifications from there using the same deviceToken and pem file.

from pushnotification.

Edujugon avatar Edujugon commented on August 25, 2024

Could you please show me the code what you're using to send the notification?

from pushnotification.

dantaylorseo avatar dantaylorseo commented on August 25, 2024
        $push = new PushNotification('apn');
        $push->setMessage([
            'aps' => [
                'alert' => "This just in!",
                'sound' => 'default'

            ],
            'extraPayLoad' => [
                'custom' => 'My custom data',
            ]
        ]);
        $push->setDevicesToken(['5a66cf3f8022a923fd7d8cf3503ca0dd91a1e26b187170e1497907188e542b5f']);
        $push->send();

from pushnotification.

dantaylorseo avatar dantaylorseo commented on August 25, 2024

@Edujugon strangely if I use the code below it works fine. I can't see much different from your code?

        $deviceToken = '5a66cf3f8022a923fd7d8cf3503ca0dd91a1e26b187170e1497907188e542b5f';

        $ctx = stream_context_create();
        stream_context_set_option($ctx, 'ssl', 'local_cert', config_path( 'iosCertificates/apns-dev-cert.pem' ) );

        // Open a connection to the APNS server
        $fp = stream_socket_client(
          'ssl://gateway.sandbox.push.apple.com:2195', $err,
          $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);

        if (!$fp)
          exit("Failed to connect: $err $errstr" . PHP_EOL);

        echo 'Connected to APNS' . PHP_EOL;

        // Create the payload body
        $body['aps'] = array(
          'alert' => "Another test",
          'sound' => 'default',
          );

        // Encode the payload as JSON
        $payload = json_encode($body);

        // Build the binary notification
        $msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($payload)) . $payload;

        // Send it to the server
        $result = fwrite($fp, $msg, strlen($msg));

        if (!$result)
          echo 'Message not delivered' . PHP_EOL;
        else
          echo 'Message successfully delivered' . PHP_EOL;

        // Close the connection to the server
        fclose($fp);

from pushnotification.

Edujugon avatar Edujugon commented on August 25, 2024

@dantaylorseo
Is the dry_run param sets as false in config file?

from pushnotification.

dantaylorseo avatar dantaylorseo commented on August 25, 2024

@Edujugon No as my device is in development

from pushnotification.

Edujugon avatar Edujugon commented on August 25, 2024

@dantaylorseo
Could I try from my side to send you a notification using the provided device token?

from pushnotification.

dantaylorseo avatar dantaylorseo commented on August 25, 2024

Yes

from pushnotification.

Edujugon avatar Edujugon commented on August 25, 2024

In order to send the test I'll need the certificate and the passPhrase.
Could you send it to [email protected]?

By the way, in the above code you say it works, you're using the apple sandbox gateway. If the certificate you're using is for testing purposes, In this package you should update the config dry_run value to true.

Could you do a try with the mentioned changes?

from pushnotification.

Edujugon avatar Edujugon commented on August 25, 2024

It was an issue when assigning the proper gateway for apn.
It has been fixed and it works as expected.

from pushnotification.

maharajay avatar maharajay commented on August 25, 2024

@Edujugon sir aim getting this error please help exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Class 'Edujugon\PushNotification\PushNotification' not found' in

from pushnotification.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.