patbef-ServiceOutside/ServiceOutsideTests/Service/Notification.cs

48 lines
2.2 KiB
C#
Raw Normal View History

2024-01-29 16:27:34 +01:00
using NUnit.Framework;
using ServiceOutside.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ServiceOutsideTests.Service
{
public class Notification
{
public Notification()
{
//string apns_cert, string bundle_id, string team_id, string key_id, APNS_TYPES apns_type, string google_json
PushNotificationsConfiguration pushNotificationsConfiguration = new PushNotificationsConfiguration(@"C:\certs\apns.p8", "de.labor-stein.Befund", "9239XBB72R", "938D85LA3G", PushNotificationsConfiguration.APNS_TYPES.PRODUCTION, "C:\\certs\\google_credential.json");
ServiceOutside.Service.Notification.SetConfigurations(pushNotificationsConfiguration);
}
[Test]
public void SendNotificationToIOS()
{
string deviceToken = "43d6d347c663273a3642557e89324d910f235d46cf64926a6eed27dd3da657c6";
ServiceOutside.Service.Notification.Message message = new ServiceOutside.Service.Notification.Message();
message.Title = "Ihr Befund ist fertig";
message.Subtitle = "Ihr Befund ist fertig und kann abgeholt werden";
message.Body = "Ihr Befund ist fertig";
bool result = ServiceOutside.Service.Notification.Send(deviceToken, ServiceShared.Models.Database.Device.DeviceTypes.IOS, message).Result;
Assert.True(result);
}
[Test]
public void SendNotificationToAndroid()
{
string deviceToken = "cGDgRBQCQnSYch196_xfle:APA91bFvIl2abAQLe4L-ZTDoh8B98xzViJ2TIrbTbxsPUEs6RN5ZbqX07_QVeAUFOTNkKXNpS39i3fyFtRr6eV_APWzRzjA6_1wLg_MLKq_J1exeuzqi5x_ZXcIZUKn8NPSg1kU6m0wS";
ServiceOutside.Service.Notification.Message message = new ServiceOutside.Service.Notification.Message();
message.Title = "Ihr Befund ist fertig";
message.Subtitle = "Ihr Befund ist fertig und kann abgeholt werden";
message.Body = "Ihr Befund ist fertig";
bool result = ServiceOutside.Service.Notification.Send(deviceToken, ServiceShared.Models.Database.Device.DeviceTypes.ANDROID, message).Result;
Assert.True(result);
}
}
}