Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up unregistered devices on notification channels? #127

Open
scramatte opened this issue Oct 30, 2020 · 0 comments
Open

Clean up unregistered devices on notification channels? #127

scramatte opened this issue Oct 30, 2020 · 0 comments

Comments

@scramatte
Copy link

Hi,

I would like to clean up unregistered device tokens from my database on notification channels.

Following code works as expected with manual push message.

        $user = User::where('username', 'abc')->first();

         $tokensApns = $user->pushTokens()->where('type', 'APNS')->pluck('token')->toArray();
        dump($tokensApns);

        $push = new PushNotification('apn');

        $payload = [
                'aps' => [
                        'alert' => 'Hola mundo',
                        'badge' => 1,
                        'sound' => 'default'
                ]
        ];

        $push->setMessage($payload)
              ->setDevicesToken($tokensApns)
              ->send();
        $feedback = $push->getFeedback();
        dump($feedback);

        UserPushToken::whereIn('token', $feedback->tokenFailList)->delete();

But how can I achieve the same thing into "toApn" method ? Moreover my Notifications are queued so where/when/how can I catch invalid tokens ?

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant