{"id":22319410,"url":"https://github.com/adessoturkey-dotnet/adspush","last_synced_at":"2025-07-29T13:31:49.340Z","repository":{"id":65690911,"uuid":"441974019","full_name":"adessoTurkey-dotNET/AdsPush","owner":"adessoTurkey-dotNET","description":"AdsPush is a server-side push notification library designed to work seamlessly across the most common .NET platforms. With full support for APNS (Apple Push Notification Service), FCM (Firebase Cloud Messaging), and VAPID WebPush, it offers a comprehensive solution for your push notification needs. Engineered for both ease of use and flexibility, ","archived":false,"fork":false,"pushed_at":"2024-03-21T15:20:31.000Z","size":310,"stargazers_count":15,"open_issues_count":8,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-02T13:32:53.280Z","etag":null,"topics":["apns","apple-push-notifications","fcm","firebase","firebase-cloud-messaging","notification-api","notification-service","notifications","push-notification","push-notification-android","push-notification-server","push-notifications"],"latest_commit_sha":null,"homepage":"https://www.nuget.org/packages/AdsPush","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adessoTurkey-dotNET.png","metadata":{"files":{"readme":"README-NUGET.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":"2021-12-26T20:03:56.000Z","updated_at":"2024-05-04T09:19:05.000Z","dependencies_parsed_at":"2023-02-19T00:00:57.056Z","dependency_job_id":null,"html_url":"https://github.com/adessoTurkey-dotNET/AdsPush","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adessoTurkey-dotNET%2FAdsPush","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adessoTurkey-dotNET%2FAdsPush/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adessoTurkey-dotNET%2FAdsPush/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adessoTurkey-dotNET%2FAdsPush/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adessoTurkey-dotNET","download_url":"https://codeload.github.com/adessoTurkey-dotNET/AdsPush/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228017952,"owners_count":17856841,"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":["apns","apple-push-notifications","fcm","firebase","firebase-cloud-messaging","notification-api","notification-service","notifications","push-notification","push-notification-android","push-notification-server","push-notifications"],"created_at":"2024-12-04T00:08:49.932Z","updated_at":"2024-12-04T00:08:53.751Z","avatar_url":"https://github.com/adessoTurkey-dotNET.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AdsPush\n\n**AdsPush** is the server-side push notification library that fully supports  APNS(Apple Push Notification Service) and FCM (Firebase Cloud Messaging) features and works with the the most common .NET platforms. It puts together good abstraction, easy using and full support for advanced use cases.\n\n- [NuGet](https://www.nuget.org/packages/AdsPush) \n- [Report Bug or Request Feature](https://github.com/adessoTurkey-dotNET/AdsPush/issues) \n- [Contact Me Via Mail](mailto:mail@anildursunsenel.com?subject=AdsPush) \n- [Contact Me Via Linkedin](https://www.linkedin.com/in/anıl-dursun-şenel)\n\n# Table Of Content\n\n1. [Features](#features)\n2. [Get It Started](#get-it-started)\n3. [Configuration](#configuration)\n    1. [Microsoft Dependency Injection](#microsoft-dependency-injection)\n    2. [Using Sender Instance](#using-sender-instance)\n4. [Sending notifications](#sending-notifications)\n\n# Features\n1. Abstraction sender works with APNS \u0026 FCM\n2. Full support for all functionality platform specific parameters.\n3. Support up-to-date recommended APIs.\n4. Easy to use.\n5. Advanced configuration options\n\n\n# Get It Started\n1. Install AdsPush by using the following command\n\n   ` dotnet add package AdsPush ` from dotnet cli\n\n   or  ` Install-Package AdsPush ` from package console\n\n2. Decide using platform (APNS or/and FCM) and get the required configuration files from the portal.\n3. Apply the following instructions to configure and send notifications.\n\n# Configuration\nYou have two easy options to be able configure AdsPush\n\n1. Using Microsoft Dependency Injection (recommended)\n    - Using default configuration provider (Microsoft Options Pattern)\n    - Using custom configuration provider.\n2. Using direct sender instance.\n\n### Microsoft Dependency Injection\n\nMicrosoft Dependency Injection is Microsoft's IOC library coming with .NET Core. AdsPush supports using MDI to be able to manage your push configuration and sending operations.\n\nIf you're sing .NET 6 or newer version in `Program.cs`\n\n```csharp\n\nusing AdsPush.Extensions;\n\nvar builder = WebApplication.CreateBuilder(args);\n//Option 1:From configuration\nbuilder.Services.AddAdsPush(this.Configuration);\n    \n//Option 2:From Action\nbuilder.Services.AddAdsPush(options =\u003e \n{\n    //Your configurations\n});\n    \n//Option 3:From custom provider that is implementation of IAdsPushConfigurationProvider interface.\nbuilder.Services.AddAdsPush\u003cMyProvider\u003e();\n```\nIf you're sing .NET 5 or any .NET Core version in `Startup.cs`\n\n```csharp\nusing AdsPush.Extensions;\n...\n\n public override void ConfigureServices(IServiceCollection services)\n {\n    //your code...\n    \n    //Option 1:From configuration\n    services.AddAdsPush(this.Configuration);\n    \n    //Option 2:From Action\n    services.AddAdsPush(options =\u003e \n    {\n        //Your configurations\n    });\n    \n    //Option 3:From custom provider that is implementation of IAdsPushConfigurationProvider interface.\n    services.AddAdsPush\u003cMyProvider\u003e();\n    \n}   \n```\n\n\nAnd put the following section in your in your `appsettings.[ENV].json`\n\n```\n{\n  \"Logging\": {\n  ...\n  },\n  \"AdsPush\": {\n    \"MyApp\": { \n      \"TargetMappings\": {\n        \"Ios\": \"Apns\",\n        \"Android\": \"FirebaseCloudMessaging\",\n        \"BrowserAndPwa\": \"VapidWebPush\"\n      },\n      \"Apns\": {\n        \"P8PrivateKey\": \"\u003cp8 certificate string without any space and start and end tags\u003e\",\n        \"P8PrivateKeyId\": \"\u003c10 digit p8 certificate id. Usually a part of a downloadable certificate filename\u003e\",\n        \"TeamId\": \"\u003cApple 10 digit team id shown in Apple Developer Membership Page\u003e\",\n        \"AppBundleIdentifier\": \"\u003cApp slug / bundle name\u003e\",\n        \"EnvironmentType\": \"\u003cApns Env one of Development or Production\u003e\"\n      },\n      \"FirebaseCloudMessaging\": {\n        \"Type\":\"\u003ctype filed in service_account.json\u003e\",\n        \"ProjectId\":\"\u003cproject_id filed in service_account.json\u003e\",\n        \"PrivateKey\": \"\u003cprivate_key filed in service_account.json\u003e\",\n        \"PrivateKeyId\": \"\u003cprivate_key_id filed in service_account.json\u003e\",\n        \"ClientId\": \"\u003cclient_id filed in service_account.json\u003e\",\n        \"ClientEmail\": \"\u003cclient_email filed in service_account.json\u003e\",\n        \"AuthUri\": \"\u003cauth_uri filed in service_account.json\u003e\",\n        \"AuthProviderX509CertUrl\": \"\u003cauth_provider_x509_cert_url filed in service_account.json\u003e\",\n        \"TokenUri\": \"\u003cclient_x509_cert_url filed in service_account.json\u003e\",\n        \"ClientX509CertUrl\": \"\u003ctoken_uri filed in service_account.json\u003e\"\n      },\n      \"Vapid\": {\n        \"PublicKey\": \"\u003cGenerated public key as string\u003e\",\n        \"PrivateKey\": \"\u003cGenerated private key as string\u003e\",\n        \"Subject\": \"\u003cSubjects that used in VAPID JWT.\u003e\"\n      }\n    }\n  }\n ...\n}\n```\n\nIf you wish to use host/pod environment or any secret provider you can set the following environment variables.\n\n```\nAdsPush__MyApp__Apns__AppBundleIdentifier=\u003cApp slug or bundle name\u003e\nAdsPush__MyApp__Apns__EnvironmentType=\u003cAPNs environment type; either 'Development' or 'Production'\u003e\nAdsPush__MyApp__Apns__P8PrivateKey=\u003cp8 certificate string without spaces and start/end tags\u003e\nAdsPush__MyApp__Apns__P8PrivateKeyId=\u003c10-digit p8 certificate id; often part of a downloadable certificate filename\u003e\nAdsPush__MyApp__Apns__TeamId=\u003c10-digit Apple team id shown on the Apple Developer Membership Page\u003e\nAdsPush__MyApp__FirebaseCloudMessaging__AuthProviderX509CertUrl=\u003cauth_provider_x509_cert_url filed in service_account.json\u003e\nAdsPush__MyApp__FirebaseCloudMessaging__AuthUri=\u003cauth_uri filed in service_account.json\u003e\nAdsPush__MyApp__FirebaseCloudMessaging__ClientEmail=\u003cclient_email filed in service_account.json\u003e\nAdsPush__MyApp__FirebaseCloudMessaging__ClientId=\u003cclient_id filed in service_account.json\u003e\nAdsPush__MyApp__FirebaseCloudMessaging__ClientX509CertUrl=\u003ctoken_uri filed in service_account.json\u003e\nAdsPush__MyApp__FirebaseCloudMessaging__PrivateKey=\u003cprivate_key filed in service_account.json\u003e\nAdsPush__MyApp__FirebaseCloudMessaging__PrivateKeyId=\u003cprivate_key_id filed in service_account.json\u003e\nAdsPush__MyApp__FirebaseCloudMessaging__ProjectId=\u003cproject_id filed in service_account.json\u003e\nAdsPush__MyApp__FirebaseCloudMessaging__TokenUri=\u003cclient_x509_cert_url filed in service_account.json\u003e\nAdsPush__MyApp__FirebaseCloudMessaging__Type=\u003ctype filed in service_account.json\u003e\nAdsPush__MyApp__TargetMappings__Android=FirebaseCloudMessaging\nAdsPush__MyApp__TargetMappings__BrowserAndPwa=VapidWebPush\nAdsPush__MyApp__TargetMappings__Ios=Apns\nAdsPush__MyApp__Vapid__PrivateKey=\u003cGenerated private key as string\u003e\nAdsPush__MyApp__Vapid__PublicKey=\u003cGenerated public key as string\u003e\nAdsPush__MyApp__Vapid__Subject=\u003cSubjects that used in VAPID JWT\u003e\n\n```\n\nNow, you can easily use wia DI as the. following.\n\n```csharp\nprivate readonly IAdsPushSender _pushSender;\npublic MyService(\n    IAdsPushSenderFactory adsPushSenderFactory)\n{\n    this._pushSender = adsPushSenderFactory.GetSender(\"MyApp\");\n}\n\n```\n\n### Using Sender Instance\n\nThe following lines of codes can be used without any DI configuration.\n\n```csharp\n\nusing AdsPush;\nusing AdsPush.Abstraction;\nusing AdsPush.Abstraction.Settings;\n\nvar builder = new AdsPushSenderBuilder();\nvar apnsSettings = new AdsPushAPNSSettings()\n{\n    //put your configurations hare.\n};\n\nvar firebaseSettings = new AdsPushFirebaseSettings()\n{\n    //put your configurations hare.\n};\n\nvar vapidSettings = new AdsPushVapidSettings()\n{\n    //put your configurations hare.\n};\n\nvar sender = builder\n    .ConfigureApns(apnsSettings, null)\n    .ConfigureFirebase(firebaseSettings, AdsPushTarget.Android)\n    .ConfigureVapid(vapidSettings, null)\n    .BuildSender();\n  \n```\n\n## Sending notifications\n\nWhen you obtain `IAdsPushSender` instance by using one the methods shown above, you're ready to send notification. The following sample code can be used trigger a basic notification request.\n\n```csharp\n\n\nvar basicPayload = new AdsPushBasicSendPayload()\n{\n    Title = AdsPushText.CreateUsingString(\"test\"),\n    Detail = AdsPushText.CreateUsingString(\"detail\"),\n    Badge = 52,\n    Sound = \"default\",\n    Parameters = new Dictionary\u003cstring, object\u003e()\n    {\n        {\n            \"pushParam1\", \"value1\"\n        },\n        {\n            \"pushParam2\", \"value2\"\n        },\n    }\n};\n    \nvar apnDeviceToken = \"15f6fdd0f34a7e0f46301a817536f0fb1b2ab05b09b3fae02beba2854a1a2a16\";\n//var apnDeviceTokenVapid = \"{\"endpoint:\"...\", \"keys\": {\"auth\":\"...\",\"p256dh\":\"...\"}}\";\n\nawait sender.BasicSendAsync(\n    AdsPushTarget.Ios,\n    apnDeviceToken,\n    basicPayload);\n\n//For VAPID WebPush with multi parametere\nstring\n    endpoint = \"https://fcm.googleapis.com/fcm/send/cIo6QJ4MMtQ:APA91bEGHCpZdHaUS7otb5_xU1zNWe6TAqria9phFm7M_9ZIiEyr0vXj3gRHbeIJMYvp2-SAVbgNrVvl7uBvU_VTLpIA0CLBcmqXuuEktGr0U4LVLvwWBibO68spJk7D-lr8R9zPyAXE\",\n    p256dh = \"BIjydse4Rij892SJN10xx1qbxDM6GrYXSfg7TGu90CVM1WmlTYzn_79psRqseyWdER969LGLjZmnXIhHPaKTyGE\",\n    auth = \"TkLGLzFeUU3C9SJJN6dLAA\";\n\nvar subscription = VapidSubscription.FromParameters(endpoint, p256dh, auth);\nawait sender.BasicSendAsync(\n    AdsPushTarget.BrowserAndPwa,\n    subscription.ToAdsPushToken(),\n    basicPayload);\n\n```\n\nIf you wish to access whole supported parameters of the related platform, the following methods can be helpful.\n\n```csharp\n\n\n//sample for Apns\nvar apnsResult = await sender\n    .GetApnsSender()\n    .SendAsync(\n        new APNSRequest()\n        {\n            ApnsPayload = new()\n            {\n                Badge = 52,\n                Sound = \"\",\n                MutableContent = true,\n                FilterCriteria = \"\",\n                ThreadId = \"\",\n                TargetContentId = \"\",\n                Alert = new APNSAlert()\n                {\n                    Title = \"\",\n                    Body = \"\",\n                    Subtitle = \"\"\n                }\n                //more...\n            },\n            AdditionalParameters = new Dictionary\u003cstring, object\u003e()\n            {\n                {\"pushParam1\", \"value1\" },\n                {\"pushParam2\", \"value2\"},\n                {\"pushParam3\", 52},\n            }\n        },\n        \"79eb1b9e623bbca0d2b218f44a18d7b8ef59dac4da5baa9949c3e99a48eb259a\",\n        Guid.NewGuid());\n\n//sample for FCM\nvar firebaseResult = await sender\n    .GetFirebaseSender()\n    .SendToSingleAsync(new Message()\n    {\n        Token = \"\",\n        Android = new AndroidConfig()\n        {\n            Priority = Priority.High,\n        },\n        Notification = new()\n        {\n            Title = \"\",\n            Body = \"\",\n            ImageUrl = \"\"\n        }\n    });\n\n\n\n//Sample for VAPID WebPush\nvar vapidResult = await sender\n    .GetVapidSender()\n    .SendAsync(\n        subscription,\n        new VapidRequest()\n        {\n            Title = \"\",\n            Badge = \"\",\n            Message = \"\",\n            Sound = \"\",\n            Icon = \"\",\n            Image = \"\",\n            Language = \"\",\n            Silent = false,\n            Tag = \"\",\n            ClickAction = \"\",\n            VibratePattern = \"\",\n            Data = new Dictionary\u003cstring, string\u003e()\n            {\n                {\"param1\", \"value1\"}\n            }\n        });\n\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadessoturkey-dotnet%2Fadspush","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadessoturkey-dotnet%2Fadspush","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadessoturkey-dotnet%2Fadspush/lists"}