У меня есть API, который написан на VB.Net и использует PushSharp 2.2.1.Я обновляю API pushsharp для использования последней стабильной версии (4.0.10).Я использую следующую ссылку
Страница обновления Pushsharp github, которую я использую
Пример кода, который я пытаюсь преобразовать в VB.Net:
// Configuration FCM (use this section for FCM)
var config = new GcmConfiguration("APIKEY");
config.GcmUrl = "https://fcm.googleapis.com/fcm/send";
var provider = "FCM";
// Create a new broker
var gcmBroker = new GcmServiceBroker (config);
// Wire up events
gcmBroker.OnNotificationFailed += (notification, aggregateEx) => {
aggregateEx.Handle (ex => {
// See what kind of exception it was to further diagnose
if (ex is GcmNotificationException notificationException) {
// Deal with the failed notification
var gcmNotification = notificationException.Notification;
var description = notificationException.Description;
Console.WriteLine ($"{provider} Notification Failed: ID={gcmNotification.MessageId}, Desc={description}");
} else if (ex is GcmMulticastResultException multicastException) {
foreach (var succeededNotification in multicastException.Succeeded) {
Console.WriteLine ($"{provider} Notification Succeeded: ID={succeededNotification.MessageId}");
}
foreach (var failedKvp in multicastException.Failed) {
var n = failedKvp.Key;
var e = failedKvp.Value;
Console.WriteLine ($"{provider} Notification Failed: ID={n.MessageId}, Desc={e.Description}");
}
} else if (ex is DeviceSubscriptionExpiredException expiredException) {
var oldId = expiredException.OldSubscriptionId;
var newId = expiredException.NewSubscriptionId;
Console.WriteLine ($"Device RegistrationId Expired: {oldId}");
if (!string.IsNullOrWhiteSpace (newId)) {
// If this value isn't null, our subscription changed and we should update our database
Console.WriteLine ($"Device RegistrationId Changed To: {newId}");
}
} else if (ex is RetryAfterException retryException) {
// If you get rate limited, you should stop sending messages until after the RetryAfterUtc date
Console.WriteLine ($"{provider} Rate Limited, don't send more until after {retryException.RetryAfterUtc}");
} else {
Console.WriteLine ("{provider} Notification Failed for some unknown reason");
}
// Mark it as handled
return true;
});
};
gcmBroker.OnNotificationSucceeded += (notification) => {
Console.WriteLine ("{provider} Notification Sent!");
};
Однако я не вижу события
gcmBroker.OnNotificationFailed
в моем проекте VB.Net.Я попытался создать простой проект winforms (C #), и после выполнения всех основных настроек я смог увидеть событие
gcmBroker.OnNotificationFailed
.Я что-то упускаю из виду, я очень новичок в VB.Net.