简体   繁体   中英

Sending push notifications in Delphi

I am trying to use Delphi (10.3.2) code to send push notifications to specific Android devices, but can't figure out how to do it properly.

The tutorials and guides I have looked at only provide help for receiving notifications (which works very nicely), but in all of them the notifications are sent directly via the Firebase console.

Is it possible to accomplish this directly in Delphi?

Sending messages to devices through Firebase Cloud Messaging requires that you call the FCM versioned API and specify the so-called FCM Server Key. As its name implies, this key should only be used on trusted environments, such as your development machine, a server you control, or Cloud Functions. The reasons for this is that anyone who has the FCM Server Key for your project can send notifications to all users of your app. So you'll not want to include this key and functionality directly in your application code.

The common approach is to set up a server-side endpoint (eg a self-defined API that you create on something like Cloud Functions or your existing server), and call that from your application code. The server-side code can then ensure that the user is authorized to send notifications to the folks that are targeted, and call the relevant FCM API to send the messages to the devices.

This FCM API for sending messages comes in a few flavors. I'd first consider if there's an Admin SDK for your platform , as that's the easiest way to make this work. If there is no Admin SDK, you can make HTTP calls to the v1 API directly.

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