-2
ConnectionManager如何獲取在AndroidPush類中捕獲的expiredRegistrationId?如何連接在參考解決方案上觸發的事件
我這樣做是錯誤的嗎?
有關如何改進我的解決方案的任何建議?
有沒有我可以遵循的模式?
解決方案:經理
public class ConnectionManger
{
private readonly IPushManager pushManager = new PushManager();
public void NotifyAppUser(List<PushNotificationSubscription> regIds, Alert alert)
{
pushManager.PushNotification(regIds, alert);
var expiredRegistrationId = ??
}
}
解決方案:PushNotification
public class PushManager : IPushManager
{
public void PushNotification(List<PushNotificationSubscription> registeredPhone, Alert alert)
{
AndroidPush androidPush = new AndroidPush();
androidPush.Push(alert, registeredPhone);
}
}
public class AndroidPush : IPushNotificationStrategy
{
public void Push(Alert alert, List<string> registrationIds)
{
// Wait for GCM server
#region GCM Events
gcmBroker.OnNotificationFailed += (notification, aggregateEx) =>
{
var expiredRegistrationId = aggregateEx.OldId;
Q: How do i pass expiredRegistrationId to ConnectionManager class?
};
}
}
廣告失敗的屬性到類ConnectionManager,以便它可以由事件處理程序設置。 – jdweng
如果我向ConnectionManager添加失敗的屬性,AndroidPush無法設置此屬性,因爲它正由ConnectionManager引用並導致循環引用。 –
您需要使用該類的一個實例。 – jdweng