简体   繁体   English

unity IOS firebase 处理前台推送通知

[英]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.

相关问题 iOS 10.0 *处理前台推送通知 - iOS 10.0 * Handle Push notification in foreground Firebase iOS推送通知在后台和前台 - Firebase iOS Push Notification in the background and foreground Firebase Analytics iOS / Unity推送通知? - Firebase Analytics iOS/Unity Push Notification? 当应用程序在 iOS 前台时如何处理 Flutter FCM 推送通知? - How to handle Flutter FCM push notification when app in foreground for iOS? iOS如何在应用程序处于前台时处理解析JSON推送通知 - iOS How to Handle Parse JSON Push Notification when App is in Foreground iOS中的Firebase推送通知 - Firebase push notification in iOS 如何在iOS应用程序的前台同时出现多个推送通知时进行处理 - how to handle while multiple push notification comes at same time in foreground of app in iOS 反应原生 ios willPresentNotification function 不处理前台的推送通知 - react native ios willPresentNotification function doesn't handle push notification in the foreground 静默推送通知在前台 iOS 应用程序上不起作用 - Silent push notification not working on foreground iOS app Appcelerator iOS推送通知显示在前台 - Appcelerator iOS push notification displaying in foreground
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM