Code Monkey home page Code Monkey logo

lnnotificationsui's Introduction

LNNotificationsUI

LNNotificationsUI is a framework for displaying notifications similar to Apple's iOS 8 and iOS 9 notifications. It is meant to complement the native look and feel, by providing a pixel-accurate (as much as possible) recreation of the notifications.

See a video here.

PayPal Donation Button

Features

  • Native look & feel
  • Support for notifications of multiple "applications"
  • Customizable notifications
  • Different banner styles:

 

  • Settings for registered apps:

 

  • Sounds support
  • Xcode 6 framework

Adding to Your Project

###Carthage

Add the following to your Cartfile:

github "LeoNatan/LNPopupController"

###Manual

Drag the LNNotificationsUI.xcodeproj project to your project, and add LNNotificationsUI.framework to Embedded Binaries in your project target's General tab. Xcode should sort everything else on its own.

Using the Framework

###Project Integration

First import the umbrella header file:

@import LNNotificationsUI;

###Registering Applications

Before being able to post notifications, you need to register at least one application with the system. Applications provide a way to group notifications, each with its own identifier, name and icon and other settings. For example, a productivity app with an e-mail client and a calendar may register two applications, "Mail" and "Calendar" with different icons, and other more advanced settings, such calendar notifications appearing as alerts by default.

[[LNNotificationCenter defaultCenter] registerApplicationWithIdentifier:@"mail_app_identifier" name:@"Mail" icon:[UIImage imageNamed:@"MailApp"] defaultSettings:[LNNotificationAppSettings defaultNotificationAppSettings]];
[[LNNotificationCenter defaultCenter] registerApplicationWithIdentifier:@"cal_app_identifier" name:@"Calendar" icon:[UIImage imageNamed:@"CalApp"]  defaultSettings:[LNNotificationAppSettings defaultNotificationAppSettings]];

Note: For all available options for the default settings, take a look at the LNNotificationAppSettings class definition. + [LNNotificationAppSettings defaultNotificationAppSettings] is provided as a convenience for obtaining the default settings.

###Displaying Notifications

Now the system is ready to post notifications. Create a notification object, set the desired parameters and post it.

LNNotification* notification = [LNNotification notificationWithMessage:@"You've Got Mail!"];
	
[[LNNotificationCenter defaultCenter] presentNotification:notification forApplicationIdentifier:@"mail_app_identifier"];

Note: For all available notification properties, take a look at the LNNotification class definition.

###Notification Actions

In addition to displaying notifications, you can associate actions with each notification. Each notification has a default action, as well as other actions that can be attached to the notification. When the user taps a notification or the appropriate button, the provided handler block is called.

LNNotification* notification = [LNNotification notificationWithMessage:@"Welcome to LNNotificationsUI!"];
	notification.title = @"Hello World!";
	notification.soundName = @"demo.aiff";
	notification.defaultAction = [LNNotificationAction actionWithTitle:@"Default Action" handler:^(LNNotificationAction *action) {
		//Handle default action
	}];
	notification.otherActions = @[[LNNotificationAction actionWithTitle:@"Other Action 1" handler:^(LNNotificationAction *action) {
		//Handle other action here
	}], [LNNotificationAction actionWithTitle:@"Other Action 2" handler:^(LNNotificationAction *action) {
		//Handle other action here
	}]];

Note: Currently, other actions are only available when notifications are presented as alerts. Tapping on banner notifications will call the default action handler.

###Settings

To display the notification settings view controller, create an instance of LNNotificationSettingsController, either in code or storyboard and display it. This view controller will display all registered apps, and will allow the user to select how notifications are presented to him. If only one app is registered, its settings will appear in this view controller. If there two or more apps registered, a list of apps will appear and selecting an app will show its settings.

lnnotificationsui's People

Contributors

codeeagle avatar fabb avatar jtmilne avatar leonatan avatar pronebird avatar raymondchau-sinodynamic avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.