Skip to content

Commit 416313a

Browse files
committed
Apn sender test added
1 parent d8fcf67 commit 416313a

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

CorePush.Tester/Program.cs

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,61 @@
11
using System;
22
using System.Net.Http;
33
using System.Threading.Tasks;
4+
using CorePush.Apple;
45
using CorePush.Google;
56

67
namespace CorePush.Tester
78
{
89
class Program
910
{
11+
#region Apn Sender Settings
12+
13+
private const string apnBundleId = "";
14+
private const string apnP8PrivateKey = "";
15+
private const string apnP8PrivateKeyId = "";
16+
private const string apnTeamId = "";
17+
private const string apnDeviceToken = "";
18+
private const ApnServerType apnServerType = ApnServerType.Development;
19+
20+
#endregion
21+
22+
#region FCM Sender Settings
1023
private const string fcmReceiverToken = "TODO";
1124
private const string fcmSenderId = "TODO";
1225
private const string fcmServerKey = "TODO";
1326

27+
# endregion
28+
29+
private static HttpClient http = new HttpClient();
30+
1431
static async Task Main()
1532
{
16-
await SendFcmNotificationAsync();
33+
//await SendApnNotificationAsync();
34+
//await SendFcmNotificationAsync();
1735

1836
Console.WriteLine("Done!");
1937
}
2038

39+
private static async Task SendApnNotificationAsync()
40+
{
41+
var settings = new ApnSettings
42+
{
43+
AppBundleIdentifier = apnBundleId,
44+
P8PrivateKey = apnP8PrivateKey,
45+
P8PrivateKeyId = apnP8PrivateKeyId,
46+
TeamId = apnTeamId,
47+
ServerType = apnServerType,
48+
};
49+
50+
var apn = new ApnSender(settings, http);
51+
var payload = new
52+
{
53+
notification = new { body = "Hello World!" }
54+
};
55+
56+
await apn.SendAsync(payload,);
57+
}
58+
2159
private static async Task SendFcmNotificationAsync()
2260
{
2361
var settings = new FcmSettings
@@ -26,12 +64,12 @@ private static async Task SendFcmNotificationAsync()
2664
ServerKey = fcmServerKey
2765
};
2866

67+
var fcm = new FcmSender(settings, http);
2968
var payload = new
3069
{
3170
notification = new { body = "Hello World!" }
3271
};
3372

34-
var fcm = new FcmSender(settings, new HttpClient());
3573
var response = await fcm.SendAsync(fcmReceiverToken, payload);
3674
}
3775
}

0 commit comments

Comments
 (0)