我尝试使用一个信号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);
}
预期结果是,通知应仅转到目标餐厅,而不是所有其他餐厅。实际结果是我必须手动触发才能从用户应用程序发送到特定餐厅,这在应用程序开发方面是不合适的
最佳答案
听起来您正在寻找有关如何将后端事件与OneSignal集成的信息。您可以为此使用我们的API。看看我们的blog post解释如何实现所需的结果。