All Projects → ahmdx → Robin

ahmdx / Robin

Licence: mit
A multi-platform notification scheduler written in Swift.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Robin

swift-standard-clients
Client declarations and live implementations for standard iOS managers
Stars: ✭ 28 (-39.13%)
Mutual labels:  notifications, watchos
Ntfd
A lightweight notification daemon for fancy desktop integrations
Stars: ✭ 44 (-4.35%)
Mutual labels:  notifications
Push Fcm Plugin
Official Firebase Cloud Messaging plugin for Push.js v1.0 🔥
Stars: ✭ 37 (-19.57%)
Mutual labels:  notifications
Fugen
Command line tool for exporting resources and generating code from your Figma files
Stars: ✭ 41 (-10.87%)
Mutual labels:  watchos
Notify.uno
Get notified when your command is done
Stars: ✭ 38 (-17.39%)
Mutual labels:  notifications
Watchtower
A process for automating Docker container base image updates.
Stars: ✭ 9,526 (+20608.7%)
Mutual labels:  notifications
React Notifications Component
Delightful and highly customisable React Component to notify your users
Stars: ✭ 978 (+2026.09%)
Mutual labels:  notifications
Pushkit
All the required components to set up independent web push notifications 🎈
Stars: ✭ 45 (-2.17%)
Mutual labels:  notifications
Eventd
A simple daemon to track remote or local events and do actions the user wants to
Stars: ✭ 43 (-6.52%)
Mutual labels:  notifications
Cordova Plugin Firebase
Cordova plugin for Google Firebase
Stars: ✭ 997 (+2067.39%)
Mutual labels:  notifications
Onesignal Ane
OneSignal extension for Adobe AIR (iOS & Android)
Stars: ✭ 39 (-15.22%)
Mutual labels:  notifications
Sqlitelib
Easily build a custom SQLite static library for use in macOS and iOS frameworks and apps.
Stars: ✭ 38 (-17.39%)
Mutual labels:  watchos
Chrome Notifier
Google Chrome extension for PagerDuty desktop notifications.
Stars: ✭ 43 (-6.52%)
Mutual labels:  notifications
React Native Ua
React Native module for Urban Airship
Stars: ✭ 37 (-19.57%)
Mutual labels:  notifications
Laravel Notification
Example package for using the (still under development) Messages API from Nexmo as a notification channel in Laravel
Stars: ✭ 44 (-4.35%)
Mutual labels:  notifications
Discourse Push Notifications
Plugin for integrating Chrome and FireFox push notifications
Stars: ✭ 36 (-21.74%)
Mutual labels:  notifications
Toasty
A notification package for Elm apps.
Stars: ✭ 39 (-15.22%)
Mutual labels:  notifications
Builder
Prepare your Laravel apps incredibly fast, with various commands, services, facades and boilerplates.
Stars: ✭ 1,009 (+2093.48%)
Mutual labels:  notifications
Potato Library
Easy to use Utility library for Android
Stars: ✭ 45 (-2.17%)
Mutual labels:  notifications
Ehplainalert
Plain style IOS alert
Stars: ✭ 44 (-4.35%)
Mutual labels:  notifications

Robin

Platform Version Swift 4+ CI Status License Release

Robin is a notification interface for iOS and macOS that handles UserNotifications behind the scenes.

Requirements

  • iOS 10.0+
  • watchOS 3.0+
  • macOS 10.14+
  • Xcode 11.1+
  • Swift 4.2+

Communication

  • If you need help or have a question, use 'robin' tag on Stack Overflow.
  • If you found a bug or have a feature request, please open an issue.

Please do not open a pull request until a contribution guide is published.

Installation

Robin is available through both Swift Package Manager and CocoaPods.

To install using SPM:

.package(url: "https://github.com/ahmdx/Robin", from: "0.94.1"),

CocoaPods:

pod 'Robin', '~> 0.94.1'

And if you want to include the test suite in your project:

pod 'Robin', '~> 0.94.1', :testspecs => ['Tests']

Usage

import Robin

Before using Robin, you need to request permission to send notifications to users. The following requests badge, sound, and alert permissions. For all available options, refer to UNAuthorizationOptions.

Robin.settings.requestAuthorization(forOptions: [.badge, .sound, .alert]) { grant, error in
  // Handle authorization or error
}

Settings

To query for the app's notification settings, you can use Robin.settings:

let alertStyle = Robin.settings.alertStyle

alertStyle is not available on watchOS.

let authorizationStatus = Robin.settings.authorizationStatus
let enabledSettings = Robin.settings.enabledSettings

This returns an option set of all the enabled settings. If some settings are not included in the set, they may be disabled or not supported. If you would like to know if some specific setting is enabled, you can use enabledSettings.contains(.sound) for example. For more details, refer to RobinSettingsOptions.

let showPreviews = Robin.settings.showPreviews

showPreviews is not available on watchOS.

Robin automatically updates information about the app's settings when the app goes into an inactive state and becomes active again to avoid unnecessary queries. If you would like to override this behavior and update the information manually, you can use forceRefresh().

Robin.settings.forceRefresh()

Robin on watchOS does not support automatic settings refresh.

Notifications

Scheduling iOS notifications via Robin is carried over by manipulating RobinNotification objects. To create a RobinNotification object, simply call its initializer.

init(identifier: String = default, body: String, date: Date = default)

Example notification, with a unique identifier, to be fired an hour from now.

let notification = RobinNotification(body: "A notification", date: Date().next(hours: 1))

next(minutes:), next(hours:), and next(days:) are part of a Date extension.

The following table summarizes all RobinNotification properties.

Property Type Description
badge NSNumber? The number the notification should display on the app icon.
body String! The body string of the notification.
date Date! The date in which the notification is set to fire on.
delivered Bool The delivery status of the notification. read-only
identifier[1] String! A string assigned to the notification for later access.
repeats Repeats The repeat interval of the notification. One of none (default), hour, day, week, or month.
scheduled Bool The status of the notification. read-only
sound RobinNotificationSound The sound name of the notification. not available on watchOS
title String? The title string of the notification.
userInfo[2] [AnyHashable : Any]! A dictionary that holds additional information.

[1] identifier is read-only after RobinNotification is initialized.

[2] To add and remove keys in userInfo, use setUserInfo(value: Any, forKey: AnyHashable) and removeUserInfoValue(forKey: AnyHashable) respectively.

Schedule a notification

After creating a RobinNotification object, it can be scheduled using schedule(notification:).

let scheduledNotification = Robin.scheduler.schedule(notification: notification)

Now scheduledNotification is a valid RobinNotification object if it is successfully scheduled or nil otherwise.

Retrieve a notification

Simply retrieve a scheduled notification by calling notification(withIdentifier: String) -> RobinNotification?.

let scheduledNotification = Robin.scheduler.notification(withIdentifier: "identifier")

Cancel a notification

To cancel a notification, either call cancel(notification: RobinNotification) or cancel(withIdentifier: String)

Robin.scheduler.cancel(notification: scheduledNotification)
Robin.scheduler.cancel(withIdentifier: scheduledNotification.identifier)

Robin allows you to cancel all scheduled notifications by calling cancelAll()

Robin.scheduler.cancelAll()

Retrieve all delivered notifications

To retrieve all delivered notifications that are displayed in the notification center, call allDelivered(completionHandler: @escaping ([RobinNotification]) -> Void).

Robin.manager.allDelivered { deliveredNotifications in
  // Access delivered notifications
}

Remove a delivered notification

To remove a delivered notification from the notification center, either call removeDelivered(notification: RobinNotification) or removeDelivered(withIdentifier identifier: String).

Robin.manager.removeDelivered(notification: deliveredNotification)
Robin.manager.removeDelivered(withIdentifier: deliveredNotification.identifier)

Robin allows you to remove all delivered notifications by calling removeAllDelivered()

Robin.manager.removeAllDelivered()

Notes

Robin is preset to allow 60 notifications to be scheduled by iOS. The remaining four slots are kept for the app-defined notifications. These free slots are currently not handled by Robin; if you use Robin to utilize these slots, the notifications will be discarded. To change the maximum allowed, just update Robin.maximumAllowedNotifications.

Robin currently can't handle multiple notifications with the same identifier. Support for grouping notifications under the same identifier is coming soon.

Author

Ahmed Mohamed, [email protected]

License

Robin is available under the MIT license. See the LICENSE file for more info.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].