Open licon4812 opened 1 year ago
I see this is due to the Notification Model not supporting object initialization via the properties, but instead, I have to use it via the constructor.
I had to use an older style of OOP as opposed to modern day OOP in .NET
public async Task SendNotification(string name, string heading, string message)
{
//create notification
var notification = new Notification
{
AppId = _appId,
Name = name,
Headings = new StringMap(en: heading),
SmallIcon = "@mipmap/appicon",
Contents = new StringMap(en: message),
IncludedSegments = new List<string> { "Subscribed Users" },
};
var response = await _client.CreateNotificationAsync(notification);
Console.WriteLine(response);
}
public async Task SendNotification(string name, string heading, string message)
{
//create notification
var notification = new Notification(
appId: _appId,
name: name,
headings: new StringMap(en: heading),
smallIcon: "@mipmap/appicon",
contents: new StringMap(en: message),
includedSegments: new List<string> { "Subscribed Users" }
);
var response = await _client.CreateNotificationAsync(notification);
Console.WriteLine(response);
}
What happened?
The latest stable version of the library returns the following error
System.ArgumentNullException: Value cannot be null. (Parameter 'appId is a required property for Notification and cannot be null')
Steps to reproduce?
Code of Conduct