我如何自动将推送通知从服务器自动触发到我的食品配送Web应用程序?

时间:2019-06-21 13:02:11

标签: java android firebase-cloud-messaging onesignal

我尝试使用fcm信号,但是我必须手动定位要发送通知的对象,事实并非如此。每当用户向特定餐厅而非所有餐厅下订单时,通知应自动触发。

一个信号,fcm,推杆,推杆

public class MyService extends FirebaseMessagingService {
    /**
     * Called when message is received.
     *
     * @param remoteMessage Object representing the message received from Firebase Cloud Messaging.
     */


    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        super.onMessageReceived(remoteMessage);
        // TODO(developer): Handle FCM messages here.
        // If the application is in the foreground handle both data and notification messages here.
        // Also if you intend on generating your own notifications as a result of a received FCM
        // message, here is where that should be initiated. See sendNotification method below.
        RemoteMessage.Notification notification = remoteMessage.getNotification();
        Map<String, String> data = remoteMessage.getData();

        sendNotification(notification, data);
    }

预期结果是,通知应仅转到目标餐厅,而不是所有其他餐厅。实际结果是我必须手动触发才能从用户应用程序发送到特定餐厅,这在应用程序开发方面是不合适的

1 个答案:

答案 0 :(得分:0)

听起来您正在寻找有关如何将后端事件与OneSignal集成的信息。您可以为此使用我们的API。看看我们的blog post来说明如何实现所需的结果。