UrbanAirshipCore 1.2.2

C# .NET Core library for interacting with Urban Airship API.

Install-Package UrbanAirshipCore -Version 1.2.2
dotnet add package UrbanAirshipCore --version 1.2.2
<PackageReference Include="UrbanAirshipCore" Version="1.2.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add UrbanAirshipCore --version 1.2.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

UrbanAirshipCore

A .NET Core class library for calling the Urban Airship API.

This is based on <a href="https://github.com/JeffGos/urbanairsharp" alt="UrbanAirSharp">UrbanAirSharp</a> but updated to .NET Core framework. I've also added in pipeline methods and additional push options such as in-app messages.

Installation

To use UrbanAirshipCore in your C# project, you can either download the UrbanAirshipCore C# .NET libraries directly from the Github repository or, if you have the NuGet package manager installed, you can grab them automatically.

PM> Install-Package UrbanAirshipCore

Once you have the UrbanAirshipCore libraries properly referenced in your project, you can include calls to them in your code.

Add the following namespaces to use the library:

using UrbanAirshipCore;

Usage

This is intended for usage in .NET Core projects.

<a href="https://docs.urbanairship.com/api/ua/#send-push" alt="Push">Push</a>

            UrbanAirshipCoreClient client = new UrbanAirshipCoreClient("<APP_KEY>", "<APP_MASTER_SECRET>");
            Push push = new Push();

            IosChannelAudience audience = new IosChannelAudience();
            audience.IosChannel = new List<string>() { "9c36e8c7-5a73-47c0-9716-99fd3d4197d5" };

            Notification notification = new Notification();
            notification.Alert = "Hello!";

            push.DeviceTypes = "all";

            push.Audience = audience;
            push.Notification = notification;

            PushResponse pushResponse = client.Push(push);

<a href="https://docs.urbanairship.com/api/ua/#api-in-app-object" alt="Push with in-app">Push with in-app</a>

            UrbanAirshipCoreClient client = new UrbanAirshipCoreClient("<APP_KEY>", "<APP_MASTER_SECRET>");
            Push push = new Push();

            List<DeviceType> deviceTypes = new List<DeviceType>();
            deviceTypes.Add(DeviceType.Ios);
            deviceTypes.Add(DeviceType.Android);

            Notification notification = new Notification();
            notification.Alert = "This part appears on the lockscreen";

            InApp inApp = new InApp();
            inApp.Alert = "This part appears in-app!";
            inApp.DisplayType = DisplayTypeType.Banner;
            inApp.Expiry = DateTime.Parse("2015-04-01T12:00:00");
            inApp.Display = new Display();
            inApp.Display.Position = PositionType.Top;
            inApp.Actions = new Actions();
            inApp.Actions.AddTag = new List<string>() { "in-app" };

            push.DeviceTypes = deviceTypes;
            push.Notification = notification;
            push.InApp = inApp;

            PushResponse pushResponse = client.Push(push);

<a href="https://docs.urbanairship.com/api/ua/#post-api-schedule" alt="Schedule">Schedule</a>

            UrbanAirshipCoreClient client = new UrbanAirshipCoreClient("<APP_KEY>", "<APP_MASTER_SECRET>");
            Schedule schedule = new Schedule();

            schedule.Name = "Booyah Sports";
            schedule.ScheduleInfo = new ScheduleInfo();
            schedule.ScheduleInfo.ScheduleTime = DateTime.Parse("2013-04-01T18:45:00");

            Push push = new Push();

            Audience audience = new Audience(AudienceType.Tag, new List<string>() { "spoaaaarts" });
            Notification notification = new Notification();
            notification.Alert = "Booyah";

            push.Audience = audience;
            push.Notification = notification;

            schedule.Push = push;

            ScheduleCreateResponse scheduleCreateResponse = client.CreateSchedule(schedule);

<a href="https://docs.urbanairship.com/api/ua/#pipelines-api" alt="Pipeline">Pipeline</a>

            UrbanAirshipCoreClient client = new UrbanAirshipCoreClient("<APP_KEY>", "<APP_MASTER_SECRET>");

            Pipeline pipeline = new Pipeline();

            pipeline.Name = "The Darkest Pipeline";
            pipeline.Enabled = true;

            EventIdentifier immediateTrigger = new EventIdentifier();
            immediateTrigger.SimpleFirstOpen = true;
            pipeline.ImmediateTrigger = immediateTrigger;

            Push push = new Push();

            push.Audience = new Audience() { Override = "triggered" };

            List<DeviceType> deviceTypes = new List<DeviceType>();
            deviceTypes.Add(DeviceType.Ios);
            deviceTypes.Add(DeviceType.Android);

            push.DeviceTypes = deviceTypes;

            push.Notification = new Notification() { Alert = "Cool goatee, Abed" };

            pipeline.Outcome = new List<Outcome>() { new Outcome() { Push = push } };

            Timing timing = new Timing();
            timing.Delay = new Delay() { Seconds = 7200 };
            timing.Schedule = new TimingSchedule() { Type = TimingScheduleType.Local, MissBehavior = MissBehaviorType.Wait };
            timing.Schedule = new TimingSchedule() { Type = TimingScheduleType.Local };

            Daypart daypart = new Daypart();
            daypart.DaysOfWeek = new List<DaysOfWeekType>() { DaysOfWeekType.Thursday };
            daypart.AllowedTimes = new List<AllowedTime>() { new AllowedTime() { Preferred = "21:30:00" } };

            timing.Schedule.Dayparts = new List<Daypart>() { daypart };

            pipeline.Timing = timing;

            client.CreatePipeline(pipeline);

<a href="https://docs.urbanairship.com/api/ua/#api-create-template" alt="Create template">Create template</a>

            UrbanAirshipCoreClient client = new UrbanAirshipCoreClient("<APP_KEY>", "<APP_MASTER_SECRET>");

            Template template = new Template();

            template.Name = "Welcome Message";
            template.Description = "Our welcome message";

            template.Variables = new List<TemplateVariable>()
            {
                new TemplateVariable() { Key = "TITLE", Name = "Title", Description = "e.g. Mr, Ms, Dr, etc.", DefaultValue = "" },
                new TemplateVariable() { Key = "FIRST_NAME", Name = "First Name", Description = "e.g. Mr, Ms, Dr, etc.", DefaultValue = "" },
                new TemplateVariable() { Key = "LAST_NAME", Name = "Last Name", Description = "Family name", DefaultValue = null }
            };

            template.Push = new TemplatePush()
            {
                Notification = new Notification()
                {
                    Alert = "Hello {{FIRST_NAME}}, this is your welcome message!"
                }
            };

            client.CreateTemplate(template);

<a href="https://docs.urbanairship.com/api/ua/#api-template-push" alt="Push to template">Push to template</a>

            UrbanAirshipCoreClient client = new UrbanAirshipCoreClient("<APP_KEY>", "<APP_MASTER_SECRET>");

            PushTemplate pushTemplate = new PushTemplate()
            {
                Audience = new Audience(AudienceType.Ios, new List<string>() { "b8f9b663-0a3b-cf45-587a-be880946e881" }),
                MergeData = new TemplateSelector()
                {
                    TemplateId = "ef34a8d9-0ad7-491c-86b0-aea74da15161",
                    Substitutions = new Dictionary<string, string>()
                    {
                        { "FIRST_NAME", "Bob" },
                        { "LAST_NAME", "Smith" },
                        { "TITLE", "" }
                    }
                }
            };

            client.PushTemplate(pushTemplate);

UrbanAirshipCore

A .NET Core class library for calling the Urban Airship API.

This is based on <a href="https://github.com/JeffGos/urbanairsharp" alt="UrbanAirSharp">UrbanAirSharp</a> but updated to .NET Core framework. I've also added in pipeline methods and additional push options such as in-app messages.

Installation

To use UrbanAirshipCore in your C# project, you can either download the UrbanAirshipCore C# .NET libraries directly from the Github repository or, if you have the NuGet package manager installed, you can grab them automatically.

PM> Install-Package UrbanAirshipCore

Once you have the UrbanAirshipCore libraries properly referenced in your project, you can include calls to them in your code.

Add the following namespaces to use the library:

using UrbanAirshipCore;

Usage

This is intended for usage in .NET Core projects.

<a href="https://docs.urbanairship.com/api/ua/#send-push" alt="Push">Push</a>

            UrbanAirshipCoreClient client = new UrbanAirshipCoreClient("<APP_KEY>", "<APP_MASTER_SECRET>");
            Push push = new Push();

            IosChannelAudience audience = new IosChannelAudience();
            audience.IosChannel = new List<string>() { "9c36e8c7-5a73-47c0-9716-99fd3d4197d5" };

            Notification notification = new Notification();
            notification.Alert = "Hello!";

            push.DeviceTypes = "all";

            push.Audience = audience;
            push.Notification = notification;

            PushResponse pushResponse = client.Push(push);

<a href="https://docs.urbanairship.com/api/ua/#api-in-app-object" alt="Push with in-app">Push with in-app</a>

            UrbanAirshipCoreClient client = new UrbanAirshipCoreClient("<APP_KEY>", "<APP_MASTER_SECRET>");
            Push push = new Push();

            List<DeviceType> deviceTypes = new List<DeviceType>();
            deviceTypes.Add(DeviceType.Ios);
            deviceTypes.Add(DeviceType.Android);

            Notification notification = new Notification();
            notification.Alert = "This part appears on the lockscreen";

            InApp inApp = new InApp();
            inApp.Alert = "This part appears in-app!";
            inApp.DisplayType = DisplayTypeType.Banner;
            inApp.Expiry = DateTime.Parse("2015-04-01T12:00:00");
            inApp.Display = new Display();
            inApp.Display.Position = PositionType.Top;
            inApp.Actions = new Actions();
            inApp.Actions.AddTag = new List<string>() { "in-app" };

            push.DeviceTypes = deviceTypes;
            push.Notification = notification;
            push.InApp = inApp;

            PushResponse pushResponse = client.Push(push);

<a href="https://docs.urbanairship.com/api/ua/#post-api-schedule" alt="Schedule">Schedule</a>

            UrbanAirshipCoreClient client = new UrbanAirshipCoreClient("<APP_KEY>", "<APP_MASTER_SECRET>");
            Schedule schedule = new Schedule();

            schedule.Name = "Booyah Sports";
            schedule.ScheduleInfo = new ScheduleInfo();
            schedule.ScheduleInfo.ScheduleTime = DateTime.Parse("2013-04-01T18:45:00");

            Push push = new Push();

            Audience audience = new Audience(AudienceType.Tag, new List<string>() { "spoaaaarts" });
            Notification notification = new Notification();
            notification.Alert = "Booyah";

            push.Audience = audience;
            push.Notification = notification;

            schedule.Push = push;

            ScheduleCreateResponse scheduleCreateResponse = client.CreateSchedule(schedule);

<a href="https://docs.urbanairship.com/api/ua/#pipelines-api" alt="Pipeline">Pipeline</a>

            UrbanAirshipCoreClient client = new UrbanAirshipCoreClient("<APP_KEY>", "<APP_MASTER_SECRET>");

            Pipeline pipeline = new Pipeline();

            pipeline.Name = "The Darkest Pipeline";
            pipeline.Enabled = true;

            EventIdentifier immediateTrigger = new EventIdentifier();
            immediateTrigger.SimpleFirstOpen = true;
            pipeline.ImmediateTrigger = immediateTrigger;

            Push push = new Push();

            push.Audience = new Audience() { Override = "triggered" };

            List<DeviceType> deviceTypes = new List<DeviceType>();
            deviceTypes.Add(DeviceType.Ios);
            deviceTypes.Add(DeviceType.Android);

            push.DeviceTypes = deviceTypes;

            push.Notification = new Notification() { Alert = "Cool goatee, Abed" };

            pipeline.Outcome = new List<Outcome>() { new Outcome() { Push = push } };

            Timing timing = new Timing();
            timing.Delay = new Delay() { Seconds = 7200 };
            timing.Schedule = new TimingSchedule() { Type = TimingScheduleType.Local, MissBehavior = MissBehaviorType.Wait };
            timing.Schedule = new TimingSchedule() { Type = TimingScheduleType.Local };

            Daypart daypart = new Daypart();
            daypart.DaysOfWeek = new List<DaysOfWeekType>() { DaysOfWeekType.Thursday };
            daypart.AllowedTimes = new List<AllowedTime>() { new AllowedTime() { Preferred = "21:30:00" } };

            timing.Schedule.Dayparts = new List<Daypart>() { daypart };

            pipeline.Timing = timing;

            client.CreatePipeline(pipeline);

<a href="https://docs.urbanairship.com/api/ua/#api-create-template" alt="Create template">Create template</a>

            UrbanAirshipCoreClient client = new UrbanAirshipCoreClient("<APP_KEY>", "<APP_MASTER_SECRET>");

            Template template = new Template();

            template.Name = "Welcome Message";
            template.Description = "Our welcome message";

            template.Variables = new List<TemplateVariable>()
            {
                new TemplateVariable() { Key = "TITLE", Name = "Title", Description = "e.g. Mr, Ms, Dr, etc.", DefaultValue = "" },
                new TemplateVariable() { Key = "FIRST_NAME", Name = "First Name", Description = "e.g. Mr, Ms, Dr, etc.", DefaultValue = "" },
                new TemplateVariable() { Key = "LAST_NAME", Name = "Last Name", Description = "Family name", DefaultValue = null }
            };

            template.Push = new TemplatePush()
            {
                Notification = new Notification()
                {
                    Alert = "Hello {{FIRST_NAME}}, this is your welcome message!"
                }
            };

            client.CreateTemplate(template);

<a href="https://docs.urbanairship.com/api/ua/#api-template-push" alt="Push to template">Push to template</a>

            UrbanAirshipCoreClient client = new UrbanAirshipCoreClient("<APP_KEY>", "<APP_MASTER_SECRET>");

            PushTemplate pushTemplate = new PushTemplate()
            {
                Audience = new Audience(AudienceType.Ios, new List<string>() { "b8f9b663-0a3b-cf45-587a-be880946e881" }),
                MergeData = new TemplateSelector()
                {
                    TemplateId = "ef34a8d9-0ad7-491c-86b0-aea74da15161",
                    Substitutions = new Dictionary<string, string>()
                    {
                        { "FIRST_NAME", "Bob" },
                        { "LAST_NAME", "Smith" },
                        { "TITLE", "" }
                    }
                }
            };

            client.PushTemplate(pushTemplate);

Release Notes

Updated guids in response to be strings.

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.2.2 492 11/2/2017