public async Task SendNotificationToDeviceOk() { var fireBaseKey = File.ReadAllText(ValidFireBaseKeyPath); using var broker = FcmBroker.Create(fireBaseKey, true); var message = broker.CreateNotification("test notification", "type", "statistic"); var result = await broker.Send(message, ValidDeviceToken); Assert.True(result.Success); }
public async Task SendNotificationWithInvalidDeviceTokenReturnInvalidDeviceTokenError() { var fireBaseKey = File.ReadAllText(ValidFireBaseKeyPath); using var broker = FcmBroker.Create(fireBaseKey, true); var message = broker.CreateNotification("test notification", "type", "statistic"); var result = await broker.Send(message, ExpiredDeviceToken); Assert.Equal(NotificationErrorCode.InvalidDeviceToken, result.Error.Code); }
public async Task RegisterOnTopicAndSendToTopicOk() { var fireBaseKey = File.ReadAllText(ValidFireBaseKeyPath); var broker = FcmBroker.Create(fireBaseKey, true); var topicName = "statistic"; var result = await broker.RegisterToTopic(ValidDeviceToken, topicName, FcmServerKey); Assert.True(result.Success); var notification = broker.CreateNotification("test notification", "type", "statistic"); result = await broker.SendToTopic(notification, topicName); Assert.True(result.Success); }