GithubHelp home page GithubHelp logo

leonatan / lnnotificationsui Goto Github PK

View Code? Open in Web Editor NEW
789.0 30.0 115.0 20.67 MB

A framework for displaying notifications similar to Apple's iOS 8 and iOS 9 notifications.

License: MIT License

Objective-C 100.00%
notifications objective-c lnnotificationsui swift ios cocoa-touch

lnnotificationsui's Introduction

Deprecation Notice

This framework is no longer under active devlopment. With iOS 10, you can now display native system notifications inside your app. I suggest migrating to Apple's new API going forward. This framework remains useful for iOS 8 & 9 support. New features will likely not be implemented, but bugs may be fixed.


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 sub-applications
  • Customizable notifications
  • Different banner styles:

 

  • Settings for registered sub-applications:

 

  • Sounds support
  • Xcode 6 framework

Adding to Your Project

Carthage

Add the following to your Cartfile:

github "LeoNatan/LNNotificationsUI"

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.

CocoaPods

CocoaPods is not supported. There are many reasons for this. Instead of CocoaPods, use Carthage. You can continue using CocoaPods for for your other dependencies and Carthage for LNNotificationsUI.

Using the Framework

Project Integration

First import the umbrella header file:

@import LNNotificationsUI;

Registering Sub-applications

Before being able to post notifications, you need to register at least one sub-application with the system. Sub-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 sub-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

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 present it. This view controller will display all registered sub-applications, and will allow the user to select how notifications are presented to him. If only one sub-application is registered, its settings will appear in this view controller. If there two or more sub-applications registered, a list containing each sub-application will appear and and the user will be able to select modify settings seperately for each sub-application.

lnnotificationsui's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lnnotificationsui's Issues

Add a "userInfo" parameters in notification center

It would be really nice to, somehow, be able to attach a user info dictionary to a notification.

One solution is to add a method - (void)presentNotification:(LNNotification*)notification forApplicationIdentifier:(NSString*)appIdentifier userInfo:(NSDictionary*)userInfo to LNNotificationCenter.

Another solution would be to add a userInfo property to LNNotification, and update initialisers as well.

I would prefer the first solution, as it is like poster a notification to NSNotificationCenter. In this case, the user info would become the NSNotification's user info, when the LNNotification is tapped.

LNNotificationAction in swift

Hi, I am new to iOS programming and using swift for my app.
I am using LNNotification for remote notification. My requirement is to navigate to a view controller when user tabs on a notification. Can you please some sample or example for this in swift ?

Thanks
Ash

no License file

without a LICENSE file, we have to assume you're fully copyrighting this software.
given that you've open sourced it, i'm hoping you meant to release with something like an MIT license

Crash in +[LNNotificationAppSettings load] when statically compiled.

If you compile project just adding all LNNotificationsUI *.h and *m files to the project, +[LNNotificationAppSettings load] crashes on line initialising LNNotificationDefaultAppSettings pointer with BAD ACCESS exception. It seems like compiler puts const LNNotificationDefaultAppSettings pointer to read only memory segment. Removing const in LNNotificationDefaultAppSettings fixes crash. Would you accept pull request with such fix?

Layout issue with hotspot banner

Hi @LeoNatan,

I'm having an issue if I attempt to display a notification while the hotspot banner is active. It shows up correctly but after it animates away it gets stuck. Can you replicate the results ?
img_0612

iOS7 Support

It can be used in iOS7 with small fixes. Don't you have plan to support iOS7 too?

App orientation is locked but the LNNotification rotates

Hello LeoNatan,

I have used this in my Live app and currently facing some issues.

Our entire app is locked to Portrait orientation but the LNNotification gets rotated.

Ive used the pods and hence if I update he Pods then the code will be overwritten by the latest for the changes I make.

Can you provide a function to pass the orientation locked and Type (Landscape / Portrait) while registering this LNNotification View.

Module LNNotificationUI not found error.

Hello Leo,

I understand that you have stopped support for adding feature as IOS 10 already is coming with thsi implementation.

I have followed your instructions to add this library as I need this for my app which support 8.0 OS also so cannot use apples UsernotificationCenter component which is IOS 10.0 and above.

I am facing the module not found even if adding the library as project

  1. drag and drop to the main project
  2. Adding in embedded binaries.
  3. @import LNNotificationUI;

I get the Module not found error still. Can help on this please.
screen shot 2017-03-13 at 12 39 00 pm

Push to cocoapods

Would be cool to push to cocoapods, currently pulling it directly from the github repo.

Thanks!

Library not loaded, Reason: image not found

Hi @LeoNatan , i've got an error:

dyld: Library not loaded: @rpath/LNNotificationsUI.framework/LNNotificationsUI
Referenced from: /private/var/mobile/Containers/Bundle/Application/8D250AEC-6661-423F-8391-CA4719E9F3D8/xxxxx.app/xxxxx
Reason: image not found

I've followed ur steps to add LNNotificationsUI.xcodeproj to my project, and added LNNotificationsUI.framework & LNNotificationsUIAssets.xcassets to the right place as below:

screen shot 2014-11-19 at 11 14 39

And idea about this?


My envir is Xcode 6.0.1 (6A317) / Xcode 6.1 (6A1046a) with iOS 8 SDK. Target device is iPad 3 (simulator works).

Getting error in iOS9 dispatch_once

I'm getting an invoke_block error in iOS9 at the code below. Will this code be optimized for use in iOS9? Thanks.
LNNotificationAppSettings.h
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
LNNotificationAppSettings* __strong* rv = (LNNotificationAppSettings*_)&LNNotificationDefaultAppSettings;
*rv = [LNNotificationAppSettings new];
(_rv).alertStyle = LNNotificationAlertStyleBanner;
(*rv).soundEnabled = YES;
});

Memory Drainer

The framework drains as much memory as over 50 MB!
Although not many leaks, it is still very shocking.
image
image

iOS 7 is not supported

frameworks are only supported on iOS 8.0 and later. embedded dylibs/frameworks are only supported on iOS 8.0 and later (@rpath/LNNotificationsUI.framework/LNNotificationsUI) for architecture arm64

Is it possible to compile it for iOS7 ?

Thanks

Making some properties public

Hey there,

How about making the following properties public so that they can be modified?

static const NSTimeInterval LNNotificationAnimationDuration = 0.5;
static const NSTimeInterval LNNotificationFullDuration = 5.0;
static const NSTimeInterval LNNotificationCutOffDuration = 2.5;

I'm creating a Chat application, something similar to WhatsApp. Having the default duration of 5.0 and a cut off time of 2.5 is too long for me, especially if the user sends let's say 10 one line messages at once.

Also, is there a way to cancel notifications that haven't been shown yet? I don't want the notification to show if the user is in a specific section of my app. I want to cancel all the pending notifications in that case.

Thanks for making this open source btw!

Purpose of the drawer? Setting to disable it?

In my head, the little drawer at the bottom is there to pull it down and reveal the full notification center on iOS. since this is not the case with this lib, I would like to hide it. Are you interested in a PR that adds a setting to disable it?

Thanks!

background music is not resumed after notification is dismissed

After researches, seem the problem is due to a missing code after the AVPlayer is stopped.

Suggestion:
add
[[AVAudioSession sharedInstance] setActive:NO withOptions:AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation error:nil];

in - (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag
of LNNotificationCenter

How to detect swiped away status?

I would like to detect when the user swipes away a message in order to cancel all pending notifications. Is it possible to detect this status?

have a doubt in LNNotificationbannerwindow

you have a user tapped function which can be used to stop sound etc.. I am wondering if I can instantiate a view controller from this function... as in when I click the notification I should be able to navigate to another window .. how to achieve this?

Swipe the notification to ignore always acts like tapping.

Swipe the notification to ignore always acts like tapping.

I want to make the ship gesture very smooth so if user intends to ignore the message its not forcing him to enter.

Its erratic many times that ship is not smooth and always gets tapped.

Can we have the fix for this please.

Pods not installing this library

Hi I am getting this error while installing through pods, this suddenly stopped. Can you please help as this app is in Appstore now and have to release the update.

[!] /usr/bin/git clone https://github.com/CodeEagle/LNNotificationsUI.git /var/folders/hv/xz_d5sf534s2t3c_xb2fx_4h0000gn/T/d20160316-6150-1kzwn8e --single-branch --depth 1 --branch 0.0.1

Cloning into '/var/folders/hv/xz_d5sf534s2t3c_xb2fx_4h0000gn/T/d20160316-6150-1kzwn8e'...
remote: Repository not found.
fatal: repository 'https://github.com/CodeEagle/LNNotificationsUI.git/' not found

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.