{"id":13709974,"url":"https://github.com/LuckyDucko/NotificationService","last_synced_at":"2025-05-06T18:33:35.537Z","repository":{"id":52258873,"uuid":"270617378","full_name":"LuckyDucko/NotificationService","owner":"LuckyDucko","description":"Set and forget Notifications for Xamarin","archived":true,"fork":false,"pushed_at":"2021-07-29T07:13:34.000Z","size":56,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-02T12:38:57.234Z","etag":null,"topics":["android","background","csharp","ios","notifications","plugin","xamarin"],"latest_commit_sha":null,"homepage":"","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/LuckyDucko.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":"2020-06-08T10:00:12.000Z","updated_at":"2023-04-14T20:48:12.000Z","dependencies_parsed_at":"2022-09-10T04:34:11.189Z","dependency_job_id":null,"html_url":"https://github.com/LuckyDucko/NotificationService","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/LuckyDucko%2FNotificationService","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LuckyDucko%2FNotificationService/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LuckyDucko%2FNotificationService/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LuckyDucko%2FNotificationService/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LuckyDucko","download_url":"https://codeload.github.com/LuckyDucko/NotificationService/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224521490,"owners_count":17325245,"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":["android","background","csharp","ios","notifications","plugin","xamarin"],"created_at":"2024-08-02T23:00:49.564Z","updated_at":"2024-11-13T20:30:44.970Z","avatar_url":"https://github.com/LuckyDucko.png","language":"C#","funding_links":[],"categories":["Plugins"],"sub_categories":[],"readme":"# Archived\n\nPlease use https://github.com/thudugala/Plugin.LocalNotification for Notifications in Xamarin\n\n\n\n\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\n\n\n\n\u003c!-- TABLE OF CONTENTS --\u003e\n\n## Table of Contents\n\n* [Getting Started](#getting-started)\n  * [Installation](#installation)\n* [Usage](#usage)\n* [Contributing](#contributing)\n* [License](#license)\n* [Contact](#contact)\n* [Acknowledgements](#acknowledgements)\n\n\n\n\u003c!-- ABOUT THE PROJECT --\u003e\n## About The Project\n\nNotificationService aims to be a plugin that will simplify the process of adding Notifications within your Xamarin app. \nSimply provide a time and let the plugin work out the rest under the hood.\n\n\n\u003c!-- GETTING STARTED --\u003e\n## Getting Started\n\n### Installation\n\n\n**Android Setup**\n\nFor a base setup, first we need to create our notification channel in *MainActivity.cs*\nhere is an example\n```\npublic class MainActivity : Xamarin.Forms.Platform.Android.FormsAppCompatActivity\n{\npublic static readonly int NOTIFICATION_ID = 1000; \u003c-- Important that it is 1000 in current plugin\npublic static readonly string CHANNEL_ID = \"YourChannel\";\ninternal static readonly string COUNT_KEY = \"count\";\n\n        protected override void OnCreate(Bundle savedInstanceState)\n        {\n            TabLayoutResource = Resource.Layout.Tabbar;\n            ToolbarResource = Resource.Layout.Toolbar;\n            base.OnCreate(savedInstanceState);\n            CreateNotificationChannel(); \u003c--- important to call the setup function!\n\n....\nvoid CreateNotificationChannel()\n  {\n      if (Build.VERSION.SdkInt \u003c BuildVersionCodes.O)\n      {\n          // Notification channels are new in API 26 (and not a part of the\n          // support library). There is no need to create a notification\n          // channel on older versions of Android.\n          return;\n      }\n\n      var name = Resources.GetString(Resource.String.channel_name);\n      var description = GetString(Resource.String.channel_description);\n      var channel = new NotificationChannel(CHANNEL_ID, name, NotificationImportance.Max)\n      {\n          Description = description,\n          LockscreenVisibility = NotificationVisibility.Public,\n          Importance = NotificationImportance.Max,\n\n      };\n\n      var notificationManager = (NotificationManager)GetSystemService(NotificationService);\n      notificationManager.CreateNotificationChannel(channel);\n  }\n}\n```\n\nto note, in the current iteration, the plugin will use `Application.Context.Resources.GetIdentifier(\"icon\", \"mipmap\", Application.Context.PackageName)`\nto collect the icon used for Notifications.\n**iOS Setup**\n\nBy default, if the app is open, iOS will not show a notification, you can choose to override this behaviour with the following\n```\npublic class NotificationsConfiguration : UNUserNotificationCenterDelegate\n{\n    public NotificationsConfiguration()\n    {\n    }\n\n    #region Override Methods\n    public override void WillPresentNotification(UNUserNotificationCenter center, UNNotification notification, Action\u003cUNNotificationPresentationOptions\u003e completionHandler)\n    {\n        // Do something with the notification\n        Console.WriteLine(\"Active Notification: {0}\", notification);\n\n        // Tell system to display the notification anyway or use\n        // `None` to say we have handled the display locally.\n        completionHandler(UNNotificationPresentationOptions.Sound | UNNotificationPresentationOptions.Alert | UNNotificationPresentationOptions.Badge);\n    }\n    #endregion\n}\n```\n\nYou may wish to keep it as none if you show notifications internally in the app.\n\nthen, in the iOS `FinishedLaunching` override, add the following\n\n```\n  if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))\n  {\n      // Ask the user for permission to get notifications on iOS 10.0+\n      UNUserNotificationCenter.Current.RequestAuthorization(\n              UNAuthorizationOptions.Alert | UNAuthorizationOptions.Badge | UNAuthorizationOptions.Sound | UNAuthorizationOptions.CriticalAlert,\n              (approved, error) =\u003e { Console.WriteLine(approved); });\n  }\n  else if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))\n  {\n      // Ask the user for permission to get notifications on iOS 8.0+\n      var settings = UIUserNotificationSettings.GetSettingsForTypes(\n              UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound,\n              new NSSet());\n\n      UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);\n  }\n\n  UNUserNotificationCenter.Current.Delegate = new NotificationsConfiguration();\n```\n**Usage**\n\n\n\u003c!-- USAGE EXAMPLES --\u003e\n## Usage\n\n*Current limitations of this plugin is that you can queue only one notification at a time, with new notifications overwriting previous ones, this will be fixed in later versions*\n\nthe API for usage is as follows\n```\nNotificationService.ShowNotification(title: \"NotificationTitle\",\n                                     subtitle: \"Quick Notification\",\n                                      body: \"Alarming information\",\n                                      id: {currentlyUnusedSoJustPut1},\n                                      notificationTime: TimeSpan.FromMinutes(30));\n```\nThis will show the notification in 30 minutes from the current time.\n```\nNotificationService.ShowNotification(title: \"NotificationTitle\",\n                                     subtitle: \"Quick Notification\",\n                                      body: \"Alarming information\",\n                                      id: {currentlyUnusedSoJustPut1},\n                                      notificationTime: new DateTimeOffset({someTimeHere));\n```\nThis will show the alarm at {someTimeHere}. Please ensure that this time is in the future.\n\n```\nNotificationService.CancelNotification({justleaveas1})\n```\nThis will cancel the notification that you have queue'd.\n\n\nIt is setup this way as the future of this plugin involves specifying ID's and having multiple notifications lined up. \n\n***PLEASE BE WARNED, Android Doze means that once the app will bunch notifications together to save power. This currently does not affect this plugin as you can only queue one notification, but in the future this may become an issue***\n\n\u003c!-- LICENSE --\u003e\n## License\n\nThis project uses the MIT License\n\n\n\n\u003c!-- CONTACT --\u003e\n## Contact\n\nMy [Github](https://github.com/LuckyDucko),\nor reach me on the [Xamarin Slack](https://xamarinchat.herokuapp.com/),\nor on my [E-mail](tyson@logchecker.com.au)\n\nProject Link: [NotificationService](https://github.com/LuckyDucko/NotificationService)\n\n\n\n\u003c!-- ACKNOWLEDGEMENTS --\u003e\n## Acknowledgements\n* [Brimmick](https://github.com/brminnick) guided me in making some choice decisions concerning notifications.)\n* [Edsnider](https://github.com/edsnider) for providing the initial [framework](https://github.com/edsnider/LocalNotificationsPlugin)\n* [JamesMontemagno](https://github.com/jamesmontemagno) for having this [amazing visual studio plugin](https://montemagno.com/new-plugin-for-xamarin-multi-target-templates-for-visual-studio-2017/) which makes creating plugins much MUCH easier\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLuckyDucko%2FNotificationService","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FLuckyDucko%2FNotificationService","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLuckyDucko%2FNotificationService/lists"}