daltron / notificationbanner Goto Github PK
View Code? Open in Web Editor NEWThe easiest way to display highly customizable in app notification banners in iOS
License: MIT License
The easiest way to display highly customizable in app notification banners in iOS
License: MIT License
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 { }
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
If I used on iOS 8 now, ok?Whether to support iOS 8?
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!
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
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
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?
Please make the font and font sizes of the banner public so an app can integrate the banner to fit their app.
Trying to use banner.autoDismiss and it was not recognized. I checked the code that was installed by pod and it does not have any reference to autoDismiss. It is in the github version
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.
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.
Would be nice to know when the alert has been dismiss or is about to show.
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.
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.'"
I just realized if I use white custom background color or .none
the title and subtitle will become invisible.
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 :)
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
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)
Hi guys, im seeing a very weird size for status message on iPhone X, I attach an image, Would this be solved? or any hint on how Can I make it smaller, because is way to big for a status message. iPhone x Image
I tried to use it in OC, but I couldn't call its functions
If the device supports haptic feedback, allow the developer to decide what kind of haptic feedback to generate. This feature can also be enabled/disabled per notification.
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.
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.
let banner = StatusBarNotificationBanner(title: "Highest priority message")
banner.clearBannerQueue()
banner.show(on: self)
NotificationBannerQueue.default.clearBannerQueue()
Please find the attached patch file. This patch file was created on top of the Commit numbered 2c41cf4
patch.diff.zip
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.
Will this project have iOS 8 support in the future?
Is it possible to pass an optional parameter type of Any
on banner.onTap
for Banners with a Custom View ?
[!] Unable to satisfy the following requirements:
SnapKit (~> 3.0.0)
required by Podfile
SnapKit (= 3.0.2)
required by Podfile.lock
SnapKit (~> 3.2.0)
required by NotificationBannerSwift (1.0.0)
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()
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
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()
Any plan to backward support Objective C as well?
Please check cocoa pods gives me titleLabel!.type = .left
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:
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! ๐
Would it be possible to have a multiline subtitle, instead of a horizontal scrolling?
The height of the banner should auto size then..
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?
Both NotificationBanner & StatusBarNotificationBanner show underneath status bar.
How to modify the banner's default show time or show it indefinitely and then hide it manually?
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.
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)
Hello, is it available to view right to left text and make all view from right to left?
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
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.
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.
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
$ 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
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?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.