As per Firebase link, Delete token is for front end user can unsubscribe from Firebase messaging instance when site provides unsubscribe option in front end. Also front end users can block notification using browser/mobile os option directly, it is difficult to know how subscription was unsubscribed/blocked by user. Messaging.Deletetoken command has no input parameter, it will delete token of current messaging instance. This will not work for deleting token from admin side/after sending push notification as there is no input token as parameter for deletetoken.
https://firebase.google.com/docs/reference/js/v8/firebase.messaging.Messaging
I think only way is to develop nodejs code request using Firebase-admin to connect to Firebase as admin and authenticate using Firebase service account json file and then send request for delete subscription by placing authorized access token in the POST request. To get access token, Firebase has only nodejs routine (no ordinary non-modular javascript/no php).
https://developers.google.com/instance-id/reference/server#manage_registration_tokens_for_push_subscriptions
So it can only be done by nodejs server side on-request code. I already developed similar kind of code for other client but for transferring tokens from other provider to Firebase, similarly we need to do it for delete token.
Since it cannot be done using WordPress side, i will try to send nodejs on request code to you to run it in server side and I will analyze it further how to collect failed tokens in a separate table and download it. We need to use those tokens in nodejs utility to communicate it with Firebase with proper authorization using Firebase-admin (nodejs utility) to clear those tokens in Firebase. It is better to communicate it in email not in this forum.
Main Reason, why Firebase tokens can be deleted with proper authorization is security, if it is allowed in browser side/client side then it is difficult to manage Firebase cloud messaging account. I think due to security reason, Firebase restricted deletion of tokens only via Firebase-admin utility with proper authorization in header with access token and this utility is available only in server side nodejs/python/java
-
This reply was modified 2 years, 2 months ago by
Murali.
-
This reply was modified 2 years, 2 months ago by
Murali.
-
This reply was modified 2 years, 2 months ago by
Murali.