#How can I delete a push notification token when a user logs out?

1 messages · Page 1 of 1 (latest)

autumn mason
#

How can I delete a push notification token when a user logs out and re-request a fresh token when they log back in. This was relatively simple in Flutter. I am also seeing an issue that if the user denies the "allow notifications" popup I have no way of alerting them within the app to try and enable push notifications? I don't want to require the user to uninstall the app and reinstall.

radiant yoke
#

You don't get a new fresh token from FCM if i am correct. You only get a fresh token when you uninstall the app and reinstall it. If you deny push messages and later enable them again you get an token from FCM. Tested this back a few months ago. You also don't need to store the push token locally on device, only push it to you server which handles the push notifications.

#

I’ve been working with FCM and NativePHP to solve a tricky problem: getting push notifications to open a specific screen in my app using deep links. In this guide, I share how I customized the notification payload and tweaked the iOS AppDelegate.swift to handle deep links properly—even when the app is in the foreground. Perfect if you want t...

#

Listener

<?php

namespace App\Listeners;

use Illuminate\Http\Client\ConnectionException;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
use Native\Mobile\Events\PushNotification\TokenGenerated;

/**
 * Class StorePushToken
 * @package App\Listeners
 */
class StorePushToken
{
    /**
     * @param TokenGenerated $event
     * @return void
     * @throws ConnectionException
     */
    public function handle(TokenGenerated $event): void
    {
        $token = $event->token ?? null;

        Log::info('Push token generated: ' . $token . ' Storing it now');

        // Send the token to the server
      
    }
}