{"id":21940133,"url":"https://github.com/softeq/pushnotificationservice","last_synced_at":"2025-04-22T15:21:56.307Z","repository":{"id":55637464,"uuid":"155366723","full_name":"Softeq/PushNotificationService","owner":"Softeq","description":null,"archived":false,"fork":false,"pushed_at":"2020-12-16T09:03:32.000Z","size":52,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-04-13T08:19:49.082Z","etag":null,"topics":["azure-notification-hubs","dotnet","netkit","pushnotification"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Softeq.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-30T10:31:15.000Z","updated_at":"2020-12-16T09:03:35.000Z","dependencies_parsed_at":"2022-08-15T05:10:23.688Z","dependency_job_id":null,"html_url":"https://github.com/Softeq/PushNotificationService","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Softeq%2FPushNotificationService","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Softeq%2FPushNotificationService/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Softeq%2FPushNotificationService/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Softeq%2FPushNotificationService/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Softeq","download_url":"https://codeload.github.com/Softeq/PushNotificationService/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250264959,"owners_count":21402012,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["azure-notification-hubs","dotnet","netkit","pushnotification"],"created_at":"2024-11-29T02:29:07.814Z","updated_at":"2025-04-22T15:21:56.282Z","avatar_url":"https://github.com/Softeq.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"![NuGet](https://img.shields.io/nuget/v/Softeq.PushNotificationService.svg)\n![Azure DevOps builds](https://img.shields.io/azure-devops/build/SofteqDevelopment/NetKit/17.svg)\n\n# Softeq.NetKit.Services.PushNotifications\n\nSofteq.NetKit.Services.PushNotifications component simplifies the process of bringing support for Push notificaitons to your project. It's build around Azure Notification Hub and supports the following push notification platforms:\n1. Android \n2. iOS\n\n# Getting Started\n\n## Install \n1. Check-out master branch from repository;\n2. Add a reference to Softeq.NetKit.Services.PushNotifications into target project.\n\n## Configure Azure Notification Hub\n\nAdd Notification Hub settings to your ```appsettings.json``` file:\n```json\n    \"Notifications\": {\n        \"Push\": {\n            \"NotificationHub\": {\n                \"ConnectionString\": \"CONN_STR\",\n                \"HubName\": \"HUB_NAME\"\n            }\n        }\n    }\n```\n\n## Configure DI Container\n\nSofteq.NetKit.Services.PushNotifications comes with Autofac Module to register its dependencies. \nIf Autofac is used on your project, add ```PushNotificationsModule``` to the container:\n```csharp\n    builder.RegisterModule(new Softeq.NetKit.Services.PushNotifications.PushNotificationsModule());\n```\n\nIf different IoC container is used or manual registration is required, the following registrations need to be performed:\n1. Set up and register NotificationHub configuration ```AzureNotificationHubConfiguration``` in your DI container\n```csharp\n    builder.Register(context =\u003e\n            {\n                var config = context.Resolve\u003cIConfiguration\u003e();\n                return new AzureNotificationHubConfiguration(\n                    config[\"Notifications:Push:NotificationHub:ConnectionString\"],\n                    config[\"Notifications:Push:NotificationHub:HubName\"]);\n            }).SingleInstance();\n```\n\n2. Register ```IPushNotificationSubscriber``` implementation\n```csharp\n    builder.RegisterType\u003cAzureNotificationHubSender\u003e().As\u003cIPushNotificationSubscriber\u003e();\n```\n\n3. Register ```IPushNotificationSender``` implementation\n```csharp\n    builder.RegisterType\u003cAzureNotificationHubSubscriber\u003e().As\u003cIPushNotificationSender\u003e();\n```\n\n## Develop\n\nSofteq.NetKit.Services.PushNotifications comes with ```PushNotificationMessage``` that represents a simple push message with the following structure;\n```csharp\n    public class PushNotificationMessage\n    {\n        [JsonIgnore]\n        public int NotificationType { get; set; }\n\n        [JsonIgnore]\n        public string Title { get; set; } = string.Empty;\n\n        [JsonIgnore]\n        public string Body { get; set; } = string.Empty;\n\n        [JsonIgnore]\n        public int Badge { get; set; } = 0;\n        \n        [JsonIgnore]\n        public string Sound { get; set; } = \"default\";\n        \n        public virtual string GetData()\n        {\n            return JsonConvert.SerializeObject(this);\n        }\n    }\n```\n\nIf an additional properties are required to be sent with push, create custom push message class and inherit from ```PushNotificationMessage```\n```csharp\n    public class ArticleLikedPush : PushNotificationMessage\n    {\n        public ArticleLikedPush()\n        {\n            Title = \"Article liked.\";\n            Body = \"Someone liked your article. Check it out!\";\n            NotificationType = (int) PushNotificationType.ArticleLiked;\n        }\n\n        [JsonProperty(\"articleId\")]\n        public Guid ArticleId { get; set; }\n\n        [JsonProperty(\"newsHeader\")]\n        public string NewsHeader { get; set; }\n    }\n```\n\n### Localization\n\nProject supports client-side message localization by providing platform-specific localization keys:\n1. For iOS - ```loc-key``` \\ ```loc-args``` and ```title-loc-key``` \\ ```title-loc-args``` \n2. For Android - ```body_loc_key``` \\ ```body_loc_args``` and ```title_loc_key``` \\ ```title_loc_args``` \n\nTo enable client-size localization for a particular message, ```BodyLocalizationKey``` and ```TitleLocalizationKey``` properties need to be initialized with valid resource names, available in client:\n\n```csharp\n    public class ArticleLikedPush : PushNotificationMessage\n    {\n        private static string _bodyLocalizationKey = \"article_Liked_body\";\n        private static string _titleLocalizationKey = \"article_Liked_title\";\n\n        public ArticleLikedPush()\n        {\n            BodyLocalizationKey = _bodyLocalizationKey;\n            TitleLocalizationKey = _titleLocalizationKey;\n            NotificationType = (int) PushNotificationType.ArticleLiked;\n        }\n\n        [JsonProperty(\"articleId\")]\n        public Guid ArticleId { get; set; }\n\n        [JsonProperty(\"newsHeader\")]\n        public string NewsHeader { get; set; }\n\n        [JsonProperty(\"userIdWhoLikedArticle\")]\n        public string UserIdWhoLikedArticle { get; set; }\n\n        [JsonIgnore]\n        [LocalizationParameter(LocalizationTarget.Title, 1)]\n        [LocalizationParameter(LocalizationTarget.Body, 1)]\n        public string UserNameWhoLikedArticle { get; set; }\n    }\n```\n\n## Use\n\nInject ```IPushNotificationSubscriber``` into your service to subscribe or unsubscribe user device from push notifications.\n\nInject ```IPushNotificationSender``` into your service to send push notifications to registered devices.\n\n## About\n\nThis project is maintained by Softeq Development Corp.\n\nWe specialize in .NET core applications.\n\n## Contributing\n\nWe welcome any contributions.\n\n## License\n\nThe Query Utils project is available for free use, as described by the [LICENSE](/LICENSE) (MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsofteq%2Fpushnotificationservice","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsofteq%2Fpushnotificationservice","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsofteq%2Fpushnotificationservice/lists"}