Coder Social home page Coder Social logo

daltron / notificationbanner Goto Github PK

View Code? Open in Web Editor NEW
4.8K 49.0 660.0 24.99 MB

The easiest way to display highly customizable in app notification banners in iOS

License: MIT License

Swift 98.61% Ruby 0.91% Objective-C 0.48%
swift swift3 ios ios-animation ios-swift

notificationbanner's People

Contributors

alexookah avatar arfrakk avatar ben9923 avatar cbpowell avatar chickdan avatar daltron avatar ecastillo avatar jeehut avatar joseantoniogarciay avatar limorcohen avatar martinmaly21 avatar misteu avatar morgan-legal avatar mrsnow-git avatar mrweatherman208 avatar niltsh avatar oscarsilver avatar pawin avatar petrpavlik avatar pikachu987 avatar rolandkakonyi avatar ronaldoh1 avatar roostr avatar shanev avatar shayanaghajan avatar styrken avatar truongtho1603 avatar weitieda avatar xbauquet avatar yauheniyarotski avatar

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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

notificationbanner's Issues

Haptic Feedback Crash

I have a NotificationBanner appear on startup if the user is not connected to the internet. If the code is not called on the main thread, the app crashes with *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'ERROR: -[_UIFeedbackHapticOnlyEngine _deactivate] called more times than the feedback engine was activated'. I fixed it by putting all of the NotificationBanner code in DispatchQueue.main.async { }

A link to a StackOverflow post

SnapKit dependencies causing errors within code whilst using NotificationBannerSwift

I believe that NotificationBannerSwift dependencies require the use of SnapKit (> 3.2.0) but that version is only for Swift 3, SnapKit latest Swift 4 version SnapKit (> 4.0.0) must be used.
The problem is I received is when trying to use NotificationBannerSwift in Swift 4/ Xcode 9 it uses this old version of SnapKit.
I have tried to install SnapKit separately but the version conflict awn trying to install notificationBanner

iOS 9?

If I used on iOS 8 now, ok?Whether to support iOS 8?

Allow offset?

I have a second use case where I need the notification to appear below a view (which has a search bar). I've tried using a container view (essentially a dummy view) to then pass the on viewController: optional UIViewController parameter - it has a rather funny effect of animating from where I want, but goes up instead of down and disappears before it finishes its animation.

I'm using a custom view for that case, if that matters.

So - either I need the bannerPositionFrame: BannerPositionFrame! variable to be exposed, or some way to set an offset (from the top, but you could imagine it just based on whatever is passed for the bannerPosition: BannerPosition! variable.

Lastly - not that it matters here, but just wondering if the bannerPosition and bannerPositionFrame variables should be explicitly unwrapped optionals? They do start out as nil (indeed you check for that in the start of BaseNotificationBanner.show(). Of course, they're private at the moment so the class is free to tell me off; they're it's business not mine.

Thanks again - great library!

Static multiline subtitles

Hi @Daltron,

Very cool library! While implementing it we found that currently it's not possible to have multi-line subtitles instead of scrolling ones. Would it be possible to add a functionality for a static multi-line subtitles?

Thanks,
Mazvydas

Banners from the bottom?

Looks like a great library here. I'm considering a strange use case - may not fit with your intent, but figure I'll ask here. Feel free to close this feature request if it's too odd.

I'd like to have a custom view animatable from the bottom upwards. This alone would be good, but the ultimate trick-shot would be to tie it to a scroll view such that it only animates in when the scroll view is not scrolling.

Let me know if either might fit with your thinking - if so, I might help implement it too.

Thanks!
./scc

Unexpectedly found nil when setting up banner

Hello,

I am using Reachability with your NotificationBanner. For example, when there is no internet, I am displaying a status bar notification saying "No Internet Connection". I am facing this very odd bug.

At the top of my ViewController I declare a variable

var isBannerShown = false
var banner: StatusBarNotificationBanner?

I also have a function that fires when reachability changes. It will go off when you go from online -> offline and vice versa.

    func reachabilityChanged(note: Notification) {
        if banner == nil {
            banner = StatusBarNotificationBanner(title: "No Internet Connection")
            banner?.autoDismiss = false
        }
        let reachability = note.object as! Reachability
        switch reachability.connection {
            case .none:
                isBannerShown = true
                banner?.show(queuePosition: .front, on: self)
                self.isNetworkDown = true
                self.sectionIndexes = [:]
                self.tableViewIndexController.tableViewIndex.reloadData()
                self.searchBar.isUserInteractionEnabled = false
                self.sections = []
            case .cellular, .wifi:
                if isBannerShown {
                    print("Banner is currently displayed")
                    banner?.dismiss()
                    isBannerShown = false
                }
                sections = createSections()
        }
    }

This type of behavior is causing the banner to crash. I have no idea why. When I go and comment out

bannerPositionFrame = BannerPositionFrame(bannerPosition: bannerPosition,
                                                  bannerWidth: appWindow.frame.width,
                                                  bannerHeight: bannerHeight,
                                                  maxY: maximumYPosition())

everything works as normal. The app I am working on doesn't deal with different orientations. It is always in vertical mode.

Any suggestions on why this is happening?

screen shot 2017-09-24 at 2 44 09 pm

Custom Font and Font Size

Please make the font and font sizes of the banner public so an app can integrate the banner to fit their app.

Show banners infinitely

Currently, banners can be shown infinitely by passing in a large value to the duration property. It would be better if each banner had a boolean value to indicate wether or not it should be shown infinitely.

Multiline subtitles

I've read PR #14, but I think there's an alternate solution by offering a property or something like useMarquee and using a standard UILabel. Unfortunately at the moment I'm going to have to use a different library because I need multiline.

delegates?

Would be nice to know when the alert has been dismiss or is about to show.

Carthage Compatiblity

Currently one can only install NotificationBanner via CocoaPods which is a pity since Carthage is the much cleaner solution to dependency management (it's much less intrusive than CocoaPods). Support for Carthage would enable the many Carthage users to use this otherwise great library, too.

'NotificationBanner' has no member 'haptic'

I am working with Xcode 9 Beta 1 (maybe this is just a problem with code 9) and I cannot add the line banner.haptic = .heavy without getting the error "Value of type 'NotificationBanner' has no member 'haptic.'"

Request priority system

Hi ! Nice lib !
I'm thinking about extending your queue system with an arbitrary priority system (a bit like NSConstraint). You add the notification with a priority value and then the queue decide the display order instead of when it's added. We could set default like high number for error, small for info.

I don't know if I'm clear but this system would reduce dev think about should my banner go on top or on the bottom of the queue :)

SnapKit v4 for Swift 4

Hello,
Please update SnapKit dependency to v4.0 to be Swift 4.x and iOS 11 compatible.
Right now I cannot build the app.
Thanks

Carthage update failed

xcode 9 macOS 10.12

error log:

mypath/Carthage/Checkouts/NotificationBanner/NotificationBanner/Classes/StatusBarNotificationBanner.swift:49:68: error: type 'UIFont' has no member 'Weight'
        titleLabel!.font = UIFont.systemFont(ofSize: 12.5, weight: UIFont.Weight.bold)
                                                                   ^~~~~~ ~~~~~~
UIKit.UIFont:46:14: note: did you mean 'xHeight'?
    open var xHeight: CGFloat { get }
             ^
mypath/Carthage/Checkouts/NotificationBanner/NotificationBanner/Classes/NotificationBanner.swift:90:68: error: type 'UIFont' has no member 'Weight'
        titleLabel!.font = UIFont.systemFont(ofSize: 17.5, weight: UIFont.Weight.bold)
                                                                   ^~~~~~ ~~~~~~
UIKit.UIFont:46:14: note: did you mean 'xHeight'?
    open var xHeight: CGFloat { get }
             ^

** BUILD FAILED **


The following build commands failed:
	CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler
	CompileSwift normal arm64
(2 failures)

NotificationBannerUtilities is not connected to the project, v1.4.5

Carthage during buld gives: Carthage/Checkouts/NotificationBanner/NotificationBanner/Classes/BaseNotificationBanner.swift:418:16: error: use of unresolved identifier 'NotificationBannerUtilities'
return NotificationBannerUtilities.isiPhoneX()
If to open the project, you will see that file NotificationBannerUtilities.swift exists, but not connected.

Remove banners added to the Queue

There should be a way we should be able to remove the banners lined up in the BannerQueue. This is in consideration that, I added some items to the queue and I have another notification coming up, which will take highest priority and displaying the banners in the queue is of no use. I've created a patch file as well with the necessary methods.

You can access the new methods in two ways.

  1. If there is a new banner with highest priority to be displayed, create the banner using the following way. And using the same banner instance, call the clearBannerQueue() method.

let banner = StatusBarNotificationBanner(title: "Highest priority message")
banner.clearBannerQueue()
banner.show(on: self)

  1. If you just wanted to clear the bannerQueue, you can use the NotificationBannerQueue instance and clear them

NotificationBannerQueue.default.clearBannerQueue()

Please find the attached patch file. This patch file was created on top of the Commit numbered 2c41cf4
patch.diff.zip

Presentation from beneath navigation bar?

Not sure if this would be handy for other folks too but for my purposes I need to sho the notification for a longer than usual time ~20 seconds, but I'd rather cover the nav bar buttons / interactions.

iOS 8 Support

Will this project have iOS 8 support in the future?

Title label gets truncated instead of scrolling with custom duration

The titlelabel of a NotificationBanner does not scroll if a custom duration is set for the banner, instead it gets truncated at the end.
I didn't check for the subtitle or status banner.

 func successNotificationBanner(_ text: String, subtitle: String){
    showBanner(NotificationBanner(title: text, subtitle: subtitle, style: .success))
}

private func showBanner(_ banner: BaseNotificationBanner){
    //banner.duration = 2.5 <- Won't scroll with this set
    banner.show()
}

Called as

successNotificationBanner( * Really long text here * , subtitle: *Subtitle here*)

Also won't scroll doing it the standard way

let banner = NotificationBanner(title: *etc..*, subtitle: *sub*, style: .success)
banner.duration = 2.5
banner.show()

iOS Minimum Version 9.0 + Tag

Hi Dalton,

First of all, kudos on the lib, easy to use and does everything that I need!

I'm creating an issue for the minimum iOS version of the project which is actually 9.3 instead of 9.0 (as documented in the readme). I've forked and tested it and it won't create any issue.

If you do change the minimum iOS version, is it possible to create a new tag (1.4.1). I'm using Carthage and I'm not a huge fan on pointing directly to the master branch as mentioned it in the readme.

Thank again for everything!
Morgan

NotificationBanner not showing in new SpriteKit app

I'm trying to show a welcome message when my SpriteKit game opens. I tried to use the example NotificationBanner in the override func viewDidLoad() of the GameViewController, but nothing shows up. I discovered that if I have 2 banners show, then the 2nd one will show up after a delay (~5sec). Im assuming that this delay is due to the 1st one being shown. How should I deal with this? Call it from a different place within my initial view controller?

let banner = NotificationBanner(title: "Welcome back!", subtitle: "We are watching...", style: .success)
        banner.show()
        
let banner2 = NotificationBanner(title: "Welcome back again!", subtitle: "We are watching you too...", style: .success)
        banner2.show()

Some features..

Hi,
I'm not really sure how I can add a "feature request" label to an issue, but anyways.
First of all, I really like this, it's really easy to use and very clean UI wise, great work!!

Had a couple of things in mind that would be nice additions:

  • the option to disable new banners when a banner is currently active.
  • the option to easily set how long a banner is shown, and to be able to check programmatically if a banner is currently being displayed.

I would help out, but I'm currently way too busy with various projects and lots of schoolwork so I don't really have the time for it atm..

Anyways, just some things that came to my mind for possible features, thanks again! ๐Ÿ˜

Multiline subtitle

Would it be possible to have a multiline subtitle, instead of a horizontal scrolling?
The height of the banner should auto size then..

UITableViewController issue

Hi there, great lib ๐Ÿ‘

I'm having an issue using it with a UITableViewController, if I scroll the table the banner does not show at the bottom of the navBar, seems the banner scrolls with the tableView all the way to the top.

Any ideas?

Issue cocoapods

Hello, it seems there's an issue with cocoapods installation. Unable to find a specification for NotificationBannerSwift. Maybe there is a issue with the name....

captura de pantalla 2017-06-07 a las 12 24 19

toolBar view hides when banner appears

Hello, awesome library!
I have a problem: when keyboard with toolbar is active and banner appears, toolbar disappears until banner dismissed. Sometimes when i type something and banner appears again toolbar does not disappears. I do simple banner.show() so banner displays on main app window. If i show banner on my tabbarcontroller everything is fine except one thing - banner shows under status bar.
img_0640
img_0642

UIFont has no member Weight

UIFont.Weight.Bold doesn't compile and needs to be UIFontWeightBold

StatusBarNotification.swift
titleLabel!.font = UIFont.systemFont(ofSize: 12.5, weight: UIFontWeightBold)

NotificationBanner.swift
titleLabel!.font = UIFont.systemFont(ofSize: 17.5, weight: UIFontWeightBold)

Right to left error

Hello, is it available to view right to left text and make all view from right to left?

iPhoneX safe area not respected.

Hi Daltron!

You are probably already aware of this issue, but I thought it wouldn't hurt to just post it here.
So I tested this library for my project on the iPhone X, and the notifications don't seem to respect the safe area, causing it to be hidden behind the notch.

I'd fix it myself but I'm not that good with SnapKit and code constraints in general.

Thanks for your great work!

Best regards,
Joni

using from Objective-c

I'm attempting to use this from Objective-c. Running into problems though with BannerStyle enum and trying to instantiate a StatusBarNotificationBanner.

Any pointers would be appreciated.

Wrong version of Snapkit

Installed the pod to my project (written in Swift 4) and it won't work because 'NotificationBanner' uses Snapkit 3.2. Snapkit 4.0 is required for Swift 4 (see https://github.com/SnapKit/SnapKit).

Please fix asap and thanks for an amazing pod otherwise, super excited to use it.

Adjust subtitle font to fit

I have a relatively big subtitle but trying to resize the 'MarqueeLabel' wont work:

self.adjustsFontSizeToFitWidth = true
self.minimumScaleFactor = withScale
self.numberOfLines = numberOfLines

Can I change the font of the label so it can fit my text in one or two lines ? Thanks

Dependency "NotificationBanner" has no shared framework schemes

$ carthage update
*** Fetching NotificationBanner
*** Checking out NotificationBanner at "1.2.0"
*** xcodebuild output can be found in /var/folders/3d/0_7l4jkd7pz0xpzzv56rddnh0000gn/T/carthage-xcodebuild.gg0Xl3.log
*** Skipped building NotificationBanner due to the error:
Dependency "NotificationBanner" has no shared framework schemes

If you believe this to be an error, please file an issue with the maintainers at https://github.com/Daltron/NotificationBanner/issues/new

Carthage Fails to Build

I have decided to try and use Carthage for our new framework, but when I use github "Daltron/NotificationBanner" ~> 1.4.0 I get several build errors. I was able to get everything working with github "Daltron/NotificationBanner" == 1.3.3. Is this something I'm messing up or is there a problem with the latest?

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.