• Resolved Nifty

    (@niftythree)


    Hi Murali,

    When specific tokens are deleted in the PNFPB plugin, they are removed immediately from the token list (which is great).

    When we send a notification through the online Firebase console (for example, a Notification campaign, so that we can insert certain directives for our app), the devices with specific tokens deleted through the plugin still receive notifications. Would it be possible for these tokens to be unsubscribed/deleted from Firebase when the token is deleted from the PNFPB plugin, to prevent this from happening?

    Thanks.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Murali

    (@murali-indiacitys)

    Javascript routine messaging.deletetoken is available from Firebase but they do not have php routines for firebase messaging. Since we are using php to delete tokens in device tokens list, i will try to add ajax routine to trigger javascript to remove tokens in Firebase and then delete it in our local database but still i have to do more analysis on how to merge it in WP_LIST_TABLE logic which is standard admin table class from WordPress.

    For failed tokens after sending push notification, it is difficult to clear out from Firebase as we send notification using wp_remote_post, i think, separate table is needed for failed tokens and by using javascript routine, we can clear out those tokens directly in Firebase

    I will do more analysis on this to do it in more easier way. Main problem is Firebase routines are designed in nodejs, javascript, python, java, kotlin but not in PHP. Since WordPress is in PHP, We need to depend on ajax routines to call JS and PHP to communicate with Firebase. Atleast if Firebase console has device tokens list showing active/unsubscribed tokens then it will be easy to delete directly in Firebase console itself but Firebase do not have that facility also.

    Thread Starter Nifty

    (@niftythree)

    Thanks, Murali. We appreciate your thorough reply and sharing that information. We’ll look forward to hearing about your progress. ??

    Plugin Author Murali

    (@murali-indiacitys)

    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.
    Thread Starter Nifty

    (@niftythree)

    Hi Murali,

    Thank you for looking into it. It does seem Firebase has made it not as straightforward as it probably should be. We are glad to hear that you may have a solution to it. However, it may be a bit too complex for us to try out at this point in time with our level of expertise. If you know someone else that’s a bit more comfortable with trying out the potential solution, then that’s probably ideal. We wouldn’t want you to spend time on something we won’t be able to help you test at this current time. We can work around it by sending on-demand push notifications from the PNFPB plugin directly. This will be fine for us for the time being. ??

    When we delete selected tokens (done manually at the moment), we can take note of the device tokens prior to deleting them from the PNFPB token list. If we are able to implement a solution like the one you mentioned, in the future, would the noted device tokens be enough to send to Firebase to request they be deleted? Should there be something else we should note?

    Thanks.

    Plugin Author Murali

    (@murali-indiacitys)

    Please store only subscription token alone. Firebase admin api requires only token for deletion with proper authentication. I will send you Firebase admin server side code after completing 1.52 release of this plugin. In 1.52 release I am including Front end subscription new menu under user profile of BuddyPress under settings menu. So that Front end users can control subscription according to their interest from their user profile menu. Apart from that Following will be in 1.52 release

    1. Front end subscription new custom menu under BuddyPress user profile settings

    2. total items display correction in device token list admin tab ,

    3. apostrophe in on demand notification

    4. hook to trigger private messages push notification for the users who uses bp-better messages plugin

    5. Action scheduler warning messages fix

    I am planning to release 1.52 this week and then I will send you server side code (in nodejs) to delete token in Firebase

    • This reply was modified 2 years, 1 month ago by Murali.
    Thread Starter Nifty

    (@niftythree)

    Hi Murali,

    Thank you for confirming we can save the subscription tokens.
    That all sounds great; we’ll look forward to the update. ??

    Thanks.

    Plugin Author Murali

    (@murali-indiacitys)

    In latest 1.53 release, I have added click url under data in payload for webview/mobile app push notifications for all push notifications. So that webview mobile app/native/hybrid mobile app parse payload to get click url from data and get parameters required to redirect the app to appropriate screen.

    • This reply was modified 2 years, 1 month ago by Murali.
    Thread Starter Nifty

    (@niftythree)

    Thanks for the ongoing updates, Murali. We’ll mark this ticket as resolved for now, and will revisit this in the future if needed. ??

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Unsubscribing deleted tokens from Firebase’ is closed to new replies.