简体   繁体   中英

Send android app device token to WordPress web from a TWA

I'm building a TWA which opens a WordPress site and shows some data addressed to a few numbers of users. Each user must see specific information according to his/her place in a chain of orders and, thus, receive different notifications.

Now, on certain WP events (creating a custom post type post, for instance), PHP Performs an HTTP request with wp_remote_post to send notifications throughout Firebase to ALL the devices carrying the app, which is less than ideal.

So, I suppose the way to narrow down the sending of notifications is to get the token of each app (TWA), store in WordPress in the wp_usermeta table (so it is linked to each different user) and use it to send tailored notifications according to the events going on in the site.

Well, that's my question:

Is there any way to send this tokens securely from the TWA to WordPress as easy and straightforward as possible?

Thanks!

In most cases, the best way to implement push notifications in a Trusted Web Activity is to implement web push notifications in the Progressive Web App and then enable Notification Delegation in the Trusted Web Activity.

In the cases where this is not the best solution, you can use custom HTTP headers to send information from the Android app to the Trusted Web Activity (assuming query strings are not desirable due to security).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM