public void CreateNotificationJsonTest() { PushNotificationCreate push = new PushNotificationCreate(); push.ApplicationId = "950a66d5-c457-4c9e-9a8b-cca7ef8b8c68"; push.Headings = new Dictionary<string, string>(); push.Headings.Add("en", "StationCAD - New Message"); push.Contents = new Dictionary<string, string>(); push.Contents.Add("en", "Server API Test Mesage"); push.IncludeSegments = new List<string> { "All" }; push.SendiOS = false; try { string json = JsonUtil<PushNotificationCreate>.ToJson(push); Console.WriteLine(json); } catch(Exception ex) { Console.WriteLine(ex.ToString()); } }
public PushNotificationCreate GetPushNotification() { PushNotificationCreate push = new PushNotificationCreate(); StringBuilder sb = new StringBuilder(); push.Headings = new Dictionary<string, string>(); push.Headings.Add("en", string.Format("{0} - {1}", this.Organization.Name, this.IncidentTypeCode)); push.Url = "http://station-cad.graphitegear.com"; push.IncludeTags.Add(new PushNotificationTag { Key = "OrgTag", Value = this.Organization.Tag, Relation = "=" }); push.Data.Add(new KeyValuePair<string, string>("IncidentID", this.Id.ToString())); push.Contents = new Dictionary<string, string>(); push.Contents.Add("en", sb.ToString()); return push; }
protected async Task CreateNotification() { PushNotificationCreate push = new PushNotificationCreate(); push.Headings = new Dictionary<string, string>(); push.Headings.Add("en", "StationCAD - New Message"); push.Contents = new Dictionary<string, string>(); push.Contents.Add("en", "Server API Test Mesage"); push.IncludeSegments = new List<string> { "All" }; push.SendiOS = false; try { Push pushNotifier = new Push(); string result = await pushNotifier.CreatNotification(push); Console.WriteLine(result); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
/// POST OneSignal 'Create Notification' /// https://onesignal.com/api/v1/notifications /// public async Task<string> CreatNotification(PushNotificationCreate push) { push.ApplicationId = ONESIGNAL_APPID; string json = JsonUtil<PushNotificationCreate>.ToJson(push); string api = "api/v1/notifications"; string result = await OneSignalAPIPost(api, json); return result; }