[英]Unity IOS firebase handle foreground push notification
I have been using firebase unity(beta) plugin for push notification.我一直在使用 firebase unity(beta) 插件进行推送通知。 I can get push notification data when my app is opened from notification screen with this method.
使用此方法从通知屏幕打开我的应用程序时,我可以获得推送通知数据。
public void OnMessageReceived(object sender, Firebase.Messaging.MessageReceivedEventArgs e) {
Debug.Log("Received a new message");
}
But I can't get push notification data when my app is in foreground.但是当我的应用程序处于前台时,我无法获取推送通知数据。 How can I get this data?
我怎样才能得到这些数据? Anybody help?
有人帮忙吗?
This solution solved my problem.这个解决方案解决了我的问题。
public void OnTokenReceived(object sender, Firebase.Messaging.TokenReceivedEventArgs token) {
NotificationServices.GetRemoteNotification (NotificationServices.remoteNotificationCount-1);
}
Old thread but if anyone else comes across this, I was receiving messages all of the time on Android but on iOS, OnMessageReceived would not fire until I added content_available: true to the firebase notification payload.旧线程,但如果其他人遇到此问题,我一直在 Android 上接收消息,但在 iOS 上,OnMessageReceived 不会触发,直到我将 content_available: true 添加到 firebase 通知有效负载。
Now, all is good and I can trigger actions in my foreground app through arbitrary data.现在,一切都很好,我可以通过任意数据在前台应用程序中触发操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.