A very flexible message bar for iOS written in Swift.

Overview

SwiftMessages

Twitter: @TimothyMoose Version License Platform Carthage compatible

Overview

SwiftMessages is a very flexible view and view controller presentation library for iOS.

Message views and view controllers can be displayed at the top, bottom, or center of the screen, or behind navigation bars and tab bars. There are interactive dismiss gestures including a fun, physics-based one. Multiple background dimming modes. And a lot more!

In addition to the numerous configuration options, SwiftMessages provides several good-looking layouts and themes. But SwiftMessages is also designer-friendly, which means you can fully and easily customize the view:

  • Copy one of the included nib files into your project and change it.
  • Subclass MessageView and add elements, etc.
  • Or just supply an arbitrary instance of UIView.

Try exploring the demo app via appetize.io to get a feel for the extensive configurability of SwiftMessages.

View Controllers

SwiftMessages can present view controllers using the SwiftMessagesSegue custom modal segue!

SwiftMessagesSegue is a subclass of UIStoryboardSegue that integrates directly into Interface Builder as a custom modal segue, enabling view controllers to take advantage of SwiftMessages layouts, animations and more. SwiftMessagesSegue works with any UIKIt project — storyboards are not required. Refer to the View Controllers readme below for more information.

View Controllers Readme

And check out our blog post Elegant Custom UIViewController Transitioning to learn a great technique you can use to build your own custom segues that utilize UIViewControllerTransitioningDelegate and UIViewControllerAnimatedTransitioning.

Installation

Swift Package Manager

Go to File | Swift Packages | Add Package Dependency... in Xcode and search for "SwiftMessages". If multiple results are found, select the one owned by SwiftKick Mobile.

CocoaPods

Add the following line to your Podfile:

pod 'SwiftMessages'

Carthage

Add the following line to your Cartfile:

github "SwiftKickMobile/SwiftMessages"

If the Carthage build fails, try using the script.

Manual

  1. Put SwiftMessages repo somewhere in your project directory.
  2. In Xcode, add SwiftMessages.xcodeproj to your project.
  3. On your app's target, add the SwiftMessages framework:
    1. as an embedded binary on the General tab.
    2. as a target dependency on the Build Phases tab.

Usage

Basics

SwiftMessages.show(view: myView)

Although you can show any instance of UIView, SwiftMessages provides a MessageView class and assortment of nib-based layouts that should handle most cases:

// Instantiate a message view from the provided card view layout. SwiftMessages searches for nib
// files in the main bundle first, so you can easily copy them into your project and make changes.
let view = MessageView.viewFromNib(layout: .cardView)

// Theme message elements with the warning style.
view.configureTheme(.warning)

// Add a drop shadow.
view.configureDropShadow()

// Set message title, body, and icon. Here, we're overriding the default warning
// image with an emoji character.
let iconText = ["🤔", "😳", "🙄", "😶"].randomElement()!
view.configureContent(title: "Warning", body: "Consider yourself warned.", iconText: iconText)

// Increase the external margin around the card. In general, the effect of this setting
// depends on how the given layout is constrained to the layout margins.
view.layoutMarginAdditions = UIEdgeInsets(top: 20, left: 20, bottom: 20, right: 20)

// Reduce the corner radius (applicable to layouts featuring rounded corners).
(view.backgroundView as? CornerRoundingView)?.cornerRadius = 10

// Show the message.
SwiftMessages.show(view: view)

You may wish to use the view provider variant show(viewProvider:) to ensure that your UIKit code is executed on the main queue:

SwiftMessages.show {
    let view = MessageView.viewFromNib(layout: .cardView)
    // ... configure the view
    return view
}

The SwiftMessages.Config struct provides numerous configuration options that can be passed to show():

var config = SwiftMessages.Config()

// Slide up from the bottom.
config.presentationStyle = .bottom

// Display in a window at the specified window level.
config.presentationContext = .window(windowLevel: .statusBar)

Note that, as of iOS 13, it is no longer possible to cover the status bar
regardless of the window level. A workaround is to hide the status bar instead.
config.prefersStatusBarHidden = true

// Disable the default auto-hiding behavior.
config.duration = .forever

// Dim the background like a popover view. Hide when the background is tapped.
config.dimMode = .gray(interactive: true)

// Disable the interactive pan-to-hide gesture.
config.interactiveHide = false

// Specify a status bar style to if the message is displayed directly under the status bar.
config.preferredStatusBarStyle = .lightContent

// Specify one or more event listeners to respond to show and hide events.
config.eventListeners.append() { event in
    if case .didHide = event { print("yep") }
}

SwiftMessages.show(config: config, view: view)

Specify default configuration options:

SwiftMessages.defaultConfig.presentationStyle = .bottom

// Show message with default config.
SwiftMessages.show(view: view)

// Customize config using the default as a base.
var config = SwiftMessages.defaultConfig
config.duration = .forever
SwiftMessages.show(config: config, view: view)

Accessibility

SwiftMessages provides excellent VoiceOver support out-of-the-box.

  • The title and body of the message are combined into a single announcement when the message is shown. The MessageView.accessibilityPrefix property can be set to prepend additional clarifying text to the announcement.

    Sometimes, a message may contain important visual cues that aren't captured in the title or body. For example, a message may rely on a yellow background to convey a warning rather than having the word "warning" in the title or body. In this case, it might be helpful to set MessageView.accessibilityPrefix = "warning".

  • If the message is shown with a dim view using config.dimMode, elements below the dim view are not focusable until the message is hidden. If config.dimMode.interactive == true, the dim view itself will be focusable and read out "dismiss" followed by "button". The former text can be customized by setting the config.dimModeAccessibilityLabel property.

See the AccessibleMessage protocol for implementing proper accessibility support in custom views.

Keyboard Avoidance

The KeyboardTrackingView class can be used to cause the message view to avoid the keyboard by sliding up when the keyboard gets too close.

var config = SwiftMessages.defaultConfig
config.keyboardTrackingView = KeyboardTrackingView()

You can incorporate KeyboardTrackingView into your app even when you're not using SwiftMessages. Install into your view hierarchy by pinning KeyboardTrackingView to the bottom, leading, and trailing edges of the screen. Then pin the bottom of your content that should avoid the keyboard to the top KeyboardTrackingView. Use an equality constraint to strictly track the keyboard or an inequality constraint to only move when the keyboard gets too close. KeyboardTrackingView works by observing keyboard notifications and adjusting its height to maintain its top edge above the keyboard, thereby pushing your content up. See the comments in KeyboardTrackingView for configuration options.

Message Queueing

You can call SwiftMessages.show() as many times as you like. SwiftMessages maintains a queue and shows messages one at a time. If your view implements the Identifiable protocol (like MessageView), duplicate messages will be removed automatically. The pause between messages can be adjusted:

SwiftMessages.pauseBetweenMessages = 1.0

There are a few ways to hide messages programatically:

// Hide the current message.
SwiftMessages.hide()

// Or hide the current message and clear the queue.
SwiftMessages.hideAll()

// Or for a view that implements `Identifiable`:
SwiftMessages.hide(id: someId)

// Or hide when the number of calls to show() and hideCounted(id:) for a 
// given message ID are equal. This can be useful for messages that may be
// shown from  multiple code paths to ensure that all paths are ready to hide.
SwiftMessages.hideCounted(id: someId)

Multiple instances of SwiftMessages can be used to show more than one message at a time. Note that the static SwiftMessages.show() and other static APIs on SwiftMessage are just convenience wrappers around the shared instance SwiftMessages.sharedInstance). Instances must be retained, thus it should be a property of something (e.g. your view controller):

class SomeViewController: UIViewController {
    let otherMessages = SwiftMessages()	
	
    func someMethod() {
        SwiftMessages.show(...)
        otherMessages.show(...)
    }
}

Retrieving Messages

There are several APIs available for retrieving messages that are currently being shown, hidden, or queued to be shown. These APIs are useful for updating messages when some event happens without needing to keep temporary references around. See also eventListeners.

Customization

SwiftMessages can display any UIView. However, there are varying degrees of customization that can be done to the bundled views.

Nib Files

All of the message designs bundled with SwiftMessages have associated nib files. You are encouraged to copy any of these nib files into your project and modify them to suit your needs. SwiftMessages will load your copy of the file instead of the original. Nib files may be copied in Xcode using drag-and-drop.

To facilitate the use of nib-based layouts, MessageView provides some type-safe convenience methods for loading the bundled nibs:

let view = MessageView.viewFromNib(layout: .cardView)

In addition, the SwiftMessages class provides some generic loading methods:

// Instantiate MessageView from a named nib.
let view: MessageView = try! SwiftMessages.viewFromNib(named: "MyCustomNib")

// Instantiate MyCustomView from a nib named MyCustomView.nib.
let view: MyCustomView = try! SwiftMessages.viewFromNib()

MessageView Class

MessageView is a light-weight view that all of the bundled designs use. It primarily consists of the following optional @IBOutlet properties:

Element Declaration Description
Title titleLabel: UILabel? The message title.
Message body bodyLabel: UILabel? The body of the message.
Image icon iconImageView: UIImageView? An image-based icon.
Text icon iconLabel: UILabel? A text-based (emoji) alternative to the image icon.
Button button: UIButton? An action button.

The SwiftMessages nib file use MessageView as the top-level view with content connected to these outlets. The layouts are done using stack views, which means that you can remove an element by simply hiding it:

view.titleLabel.isHidden = true

A common mistake is attempting to remove an element by setting the corresponding outlet to nil. This does not work because it does not remove the element from the view hierarchy.

Configuration

MessageView provides numerous methods that follow the configure* naming convention:

view.configureTheme(.warning)
view.configureContent(title: "Warning", body: "Consider yourself warned.", iconText: "🤔")

All of these methods are shortcuts for quickly configuring the underlying view properties. SwiftMessages strives to avoid doing any internal magic in these methods, so you do not need to call them. You can configure the view properties directly or combine the two approaches.

Interaction

MessageView provides an optional block-based tap handler for the button and another for the view itself:

// Hide when button tapped
messageView.buttonTapHandler = { _ in SwiftMessages.hide() }

// Hide when message view tapped
messageView.tapHandler = { _ in SwiftMessages.hide() }

Extending

The suggested method for starting with MessageView as a base and adding new elements, such as additional buttons, is as follows:

  1. Copy one of the bundled nib files into your project or create a new one from scratch.
  2. Add new elements to the nib file.
  3. Sublcass MessageView and create outlets for the new elements.
  4. Assign the top-level view in the nib file to the subclass.
  5. Connect outlets between the nib file and the subclass.
  6. (recommended) override the implementation of Identifiable as needed to incorporate new elements into the message's identity.
  7. (recommended) override the implementation of AccessibleMessage as needed to incorporate new elements into Voice Over.
  8. Use one of the nib-loading methods above to load the view.

BaseView Class

BaseView is the superclass of MessageView and provides numerous options that aren't specific to the "title + body + icon + button" design of MessageView. Custom views that are significantly different from MessageView, such as a progress indicator, should subclass BaseView.

CornerRoundingView Class

CornerRoundingView is a custom view that messages can use for rounding all or a subset of corners with squircles (the smoother method of rounding corners that you see on app icons). The nib files that feature rounded corners have backgroundView assigned to a CornerRoundingView. It provides a roundsLeadingCorners option to dynamically round only the leading corners of the view when presented from top or bottom (a feature used for the tab-style layouts).

Animator Protocol

Animator is the protocol that SwiftMessages uses for presentation and dismissal animations. Custom animations can be done through the SwiftMessages.PresentationStyle.custom(animator:). Some related components:

  • TopBottomAnimation is a sliding implementation of Animator used internally by .top and .bottom presentation styles. It provides some customization options.
  • PhysicsAnimation is a scaling + opacity implementation of Animator used internally by the .center presentation style. It provides a fun physics-based dismissal gesture and provides customization options including .top and .bottom placement.
  • PhysicsPanHandler provides the physics-based dismissal gesture for PhysicsAnimation and can be incorporated into other Animator implementations.

High-quality PRs for cool Animator implementations are welcome!

MarginAdjustable Protocol

MarginAdjustable is a protocol adopted by BaseView. If the view being presented adopts MarginAdjustable, SwiftMessages takes ownership of the view's layout margins to ensure ideal spacing across the full range of presentation contexts.

BackgroundViewable Protocol

BackgroundViewable is a protocol adopted by BaseView and requires that a view provide a single backgroundView property. BaseView initializes backgroundView = self, which you can freely re-assign to any subview.

If the view being presented adopts BackgroundViewable, SwiftMessages will ignore touches outside of backgroundView. This is important because message views always span the full width of the device. Card and tab-style layouts appear inset from the edges of the device because the message view's background is transparent and backgroundView is assigned to a subview constrained to the layout margins. In these layouts, touches in the transparent margins should be ignored.

Identifiable Protocol

Identifiable is a protocol adopted by MessageView and requires that a view provide a single id property, which SwiftMessages uses for message deduplication.

MessageView computes the id based on the message content, but id can also be set explicitly as needed.

AccessibleMessage Protocol

AccessibleMessage is a protocol adopted by MessageView. If the view being presented adopts AccessibleMessage, SwiftMessages provides improved Voice Over.

About SwiftKick Mobile

We build high quality apps! Get in touch if you need help with a project.

License

SwiftMessages is distributed under the MIT license. See LICENSE for details.

Comments
  • Crash on jailbroken iPod Touch 6G

    Crash on jailbroken iPod Touch 6G

    Got the following crash:

    iPod Touch 6G on 9.3.3

    Crashed: com.apple.main-thread
    EXC_BREAKPOINT 0x000000010170847c
    
    Crashed: com.apple.main-thread
    0  SwiftMessages                  0x10170847c IconStyle.image(theme : Theme) -> UIImage (Theme.swift:37)
    1  ios                            0x1000fccdc static MessageManager.showInfo(String, body : String) -> () (MessageManager.swift:71)
    2  UIKit                          0x18783d944 -[UIPresentationController transitionDidFinish:] + 1320
    3  UIKit                          0x18796e418 -[_UICurrentContextPresentationController transitionDidFinish:] + 44
    4  UIKit                          0x187840b3c __56-[UIPresentationController runTransitionForCurrentState]_block_invoke_2 + 188
    5  UIKit                          0x187611114 -[_UIViewControllerTransitionContext completeTransition:] + 116
    6  UIKit                          0x187610f00 -[UITransitionView notifyDidCompleteTransition:] + 252
    7  UIKit                          0x1876109fc -[UITransitionView _didCompleteTransition:] + 1164
    8  UIKit                          0x18761055c -[UITransitionView _transitionDidStop:finished:] + 124
    9  UIKit                          0x18751bc28 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 312
    10 UIKit                          0x18751bab0 -[UIViewAnimationState animationDidStop:finished:] + 108
    11 QuartzCore                     0x184e75998 CA::Layer::run_animation_callbacks(void*) + 284
    12 libdispatch.dylib              0x181dd547c _dispatch_client_callout + 16
    13 libdispatch.dylib              0x181ddab84 _dispatch_main_queue_callback_4CF + 1844
    14 CoreFoundation                 0x182340d50 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
    15 CoreFoundation                 0x18233ebb8 __CFRunLoopRun + 1628
    16 CoreFoundation                 0x182268c50 CFRunLoopRunSpecific + 384
    17 GraphicsServices               0x183b50088 GSEventRunModal + 180
    18 UIKit                          0x18754a088 UIApplicationMain + 204
    19 ios                            0x1000ec280 main (AppDelegate.swift:24)
    20 libdyld.dylib                  0x181e068b8 start + 4```
    
    help wanted 
    opened by allaire 59
  • Xcode 13 issue - Enum cases with associated values cannot be marked potentially unavailable with '@available'

    Xcode 13 issue - Enum cases with associated values cannot be marked potentially unavailable with '@available'

    When we try to build SwiftMessages with Xcode 13 beta, the following error is being thrown: Enum cases with associated values cannot be marked potentially unavailable with '@available' Screenshot 2021-06-08 at 12 01 40 PM

    opened by rizwan95 28
  • Crash When opening Swift Messages

    Crash When opening Swift Messages

    2019-03-03 13:08:12.746937+0530 Bill Store[6852:58753] *** Assertion failure in -[UICollectionViewFlowLayout _getSizingInfosWithExistingSizingDictionary:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKitCore_Sim/UIKit-3698.93.8/UICollectionViewFlowLayout.m:1432 2019-03-03 13:08:12.751492+0530 Bill Store[6852:58753] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'negative sizes are not supported in the flow layout' *** First throw call stack: ( 0 CoreFoundation 0x00000001126451bb __exceptionPreprocess + 331 1 libobjc.A.dylib 0x0000000111be3735 objc_exception_throw + 48 2 CoreFoundation 0x0000000112644f42 +[NSException raise:format:arguments:] + 98 3 Foundation 0x0000000110a61877 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 194 4 UIKitCore 0x00000001167fe7e9 -[UICollectionViewFlowLayout _getSizingInfosWithExistingSizingDictionary:] + 3424 5 UIKitCore 0x00000001167fffc4 -[UICollectionViewFlowLayout _fetchItemsInfoForRect:] + 231 6 UIKitCore 0x00000001167f8f74 -[UICollectionViewFlowLayout collectionViewContentSize] + 49 7 UIKitCore 0x00000001167efe14 -[UICollectionViewData _validateContentSize] + 180 8 UIKitCore 0x00000001167effb2 -[UICollectionViewData _prepareToLoadData] + 276 9 UIKitCore 0x00000001167f09fb -[UICollectionViewData validateLayoutInRect:] + 53 10 UIKitCore 0x00000001167bf00e -[UICollectionView layoutSubviews] + 260 11 UIKitCore 0x000000011744c795 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1441 12 QuartzCore 0x0000000111358b19 -[CALayer layoutSublayers] + 175 13 QuartzCore 0x000000011135d9d3 ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 395 14 UIKitCore 0x0000000117437077 -[UIView(Hierarchy) layoutBelowIfNeeded] + 1429 15 SwiftMessages 0x0000000111a546b6 $S13SwiftMessages18TopBottomAnimationC7install7contextyAA0E7ContextC_tF + 1830 16 SwiftMessages 0x0000000111a533b1 $S13SwiftMessages18TopBottomAnimationC4show7context10completionyAA0E7ContextC_ySbctF + 577 17 SwiftMessages 0x0000000111a5840e $S13SwiftMessages18TopBottomAnimationCAA8AnimatorA2aDP4show7context10completionyAA0E7ContextC_ySbctFTW + 30 18 SwiftMessages 0x0000000111a2df4d $S13SwiftMessages9PresenterC13showAnimation33_9240CA0FAD7C4E3A99020B5AAC45D767LL10completionyySbc_tF + 285 19 SwiftMessages 0x0000000111a2d96a $S13SwiftMessages9PresenterC4show10completionyySbc_tKF + 682 20 SwiftMessages 0x0000000111a3e9c8 $S13SwiftMessagesAAC11dequeueNext33_AB28F0CA9BFF0B16E059C4C20EF9AFAALLyyFyycfU + 392 21 SwiftMessages 0x0000000111a47a81 $S13SwiftMessagesAAC11dequeueNext33_AB28F0CA9BFF0B16E059C4C20EF9AFAALLyyFyycfU_TA + 17 22 SwiftMessages 0x0000000111a2095d $SIeg_IeyB_TR + 45 23 libdispatch.dylib 0x0000000113688595 _dispatch_call_block_and_release + 12 24 libdispatch.dylib 0x0000000113689602 _dispatch_client_callout + 8 25 libdispatch.dylib 0x000000011369699a _dispatch_main_queue_callback_4CF + 1541 26 CoreFoundation 0x00000001125aa3e9 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 9 27 CoreFoundation 0x00000001125a4a76 __CFRunLoopRun + 2342 28 CoreFoundation 0x00000001125a3e11 CFRunLoopRunSpecific + 625 29 GraphicsServices 0x000000011a8981dd GSEventRunModal + 62 30 UIKitCore 0x0000000116f6281d UIApplicationMain + 140 31 Bill Store 0x000000010f9edf37 main + 71 32 libdyld.dylib 0x00000001136ff575 start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)

    opened by viveksinghmehta 21
  • Crashing at SwiftMessages.Config() or SwiftMessags.defaultConfig version 7.0.1

    Crashing at SwiftMessages.Config() or SwiftMessags.defaultConfig version 7.0.1

    Screen Shot 2020-10-13 at 12 50 57 AM

    version 5.0.1 working fine but when upgrading to 7.0.1 instantiate SwiftMessages.Config() or SwiftMessages.defaultConfig caused retain cycle. Hope someone can help me thank you.

    opened by Nathan2017 19
  • iOS13.1.3 compatibility issue

    iOS13.1.3 compatibility issue

    when message show on my iPad Pro(11-inch), the whole UI doesn't respond to touch event; but it's OK on iOS13.1 simulator. The code below:

    var config = SwiftMessages.defaultConfig config.presentationContext = .window(windowLevel: .normal) config.preferredStatusBarStyle = .lightContent config.duration = .seconds(seconds: 3)

    SwiftMessages.show(config: config)

    opened by woohyuknrg 18
  • Crashes when dequeueNext

    Crashes when dequeueNext

    Crashlytics is telling me we've got crashes on our app due to SwiftMessages.

    Here is the stack : Crashed: com.apple.main-thread 0 (Missing) 0x300920bd4 (Missing) 1 (Missing) 0x300920bd4 (Missing) 2 SwiftMessages 0x1009156c8 closure #1 in SwiftMessages.dequeueNext() (SwiftMessages.swift:547) 3 SwiftMessages 0x1009105f8 thunk for @escaping @callee_guaranteed () -> () () 4 libdispatch.dylib 0x186dab6c8 _dispatch_call_block_and_release + 24 5 libdispatch.dylib 0x186dac484 _dispatch_client_callout + 16 6 libdispatch.dylib 0x186d589ec _dispatch_main_queue_callback_4CF$VARIANT$mp + 1068 7 CoreFoundation 0x1873021bc CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 12 8 CoreFoundation 0x1872fd084 __CFRunLoopRun + 1964 9 CoreFoundation 0x1872fc5b8 CFRunLoopRunSpecific + 436 10 GraphicsServices 0x189570584 GSEventRunModal + 100 11 UIKitCore 0x1b4178bc8 UIApplicationMain + 212 12 snapSchool 0x100520814 main (AppDelegate.swift:25) 13 libdyld.dylib 0x186dbcb94 start + 4

    I haven't reproduced the crash yet

    XCode10, Swift 4.2, Branch : work/swift4.2

    My code calling the lib :

    func presentToastForFinishedTask(tasks : [PostQueue.TaskInfo]) {
            for task in tasks {
                let view = MessageView.viewFromNib(layout: .messageView)
                view.configureTheme(.success)
                switch task.type {
                case .answer(_, let title):
                    let body = String(format : NSLocalizedString("toast.answer.finished",comment: ""),title)
                    view.configureContent(body: body)
                    view.titleLabel?.isHidden = true
                case .exam(title: _):
                    fatalError("not supported")
                }
                view.button?.isHidden = true
    
                var config = SwiftMessages.Config()
                config.duration = .seconds(seconds: 5)
    
                SwiftMessages.show(config : config, view: view)
            }
        }
    
    opened by g-bourachot 17
  • Several Safe Area related warnings in MarginAdjustable+Animation.swift

    Several Safe Area related warnings in MarginAdjustable+Animation.swift

    Hi,

    Thanks for creating this!

    The latest release triggers a few Xcode warnings in my project in the file MarginAdjustable+Animation.swift:

    SwiftMessages/MarginAdjustable+Animation.swift:16:17: 'safeAreaTopOffset' is deprecated on iOS: Use the `topLayoutMarginAddition` instead.
    SwiftMessages/MarginAdjustable+Animation.swift:16:43: 'safeAreaBottomOffset' is deprecated on iOS: Use the `bottomLayoutMarginAddition` instead.
    SwiftMessages/MarginAdjustable+Animation.swift:16:72: 'statusBarOffset' is deprecated on iOS: Now handled by `collapseLayoutMarginAdditions`
    SwiftMessages/MarginAdjustable+Animation.swift:74:24: 'safeAreaTopOffset' is deprecated on iOS: Use the `topLayoutMarginAddition` instead.
    SwiftMessages/MarginAdjustable+Animation.swift:78:28: 'statusBarOffset' is deprecated on iOS: Now handled by `collapseLayoutMarginAdditions`
    SwiftMessages/MarginAdjustable+Animation.swift:99:27: 'safeAreaBottomOffset' is deprecated on iOS: Use the `bottomLayoutMarginAddition` instead.
    

    The deprecation warnings are coming from elsewhere in SwiftMessages. Is this intentional or..?

    opened by edwardmp 16
  • swift messages error

    swift messages error

    @srstanic @defagos @raven @qx89l4 @triskybro I updated this project using cocoapods to the latest version after upgrading to xcode 9. I use swiftmessages all over my project and this is by far the best alert I've ever seen. The old version worked perfectly but this version crashes when I try to display the alert. can you help me. I think there is a bug in this project.

    opened by Ahmedshubber 16
  • After updating to xcode 10 SwiftMessages.Config has no member presentationContext

    After updating to xcode 10 SwiftMessages.Config has no member presentationContext

    Having trouble updating my project to Xcode 10. When building I receive Value of type 'SwiftMessages.Config' has no member 'presentationContext'; did you mean 'presentationStyle'?. I am running swift version 4.0 could the latest version of SwiftMessages be built for swift 4.2, would that even have that affect? If so what version should i be on for Swift 4.0?

    SwiftMessages Version: 5.0.3 Swift version: 4.0 Xcode version: 10

    opened by stshelton 15
  • Swift Message hides automatically

    Swift Message hides automatically

    I am using swift message in a web view during some transaction process. When the transaction begins, I display an Under progress, swift message. If it takes too long, I hide the previous one and display another. But sometimes, the first message hides automatically after a few seconds, even though the config.duration is set to .forever. Running the app on device, iPhone 6. Latest Xcode and SwiftMessages version.

    question 
    opened by iamsanketray123 14
  • Alert not shown after Biometry check (only from v. 9.0.1)

    Alert not shown after Biometry check (only from v. 9.0.1)

    From version 9.0.1 my app can't display alert after Biometry check. This issue doesn't occur with older versions. If I try to show the alert after 1 sec (or more) using DispatchQueue.main.asynAfter the alert appears correctly.

    Here the code that doesn't work:

    let context = LAContext()
    var error: NSError?
    if context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) {
        context.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: reason) {
            success, authenticationError in
                if success {
                    // Show an alert
                    ...
                    SwiftMessages.show(config: config, view: view)
                }
                else { ... }
          }
    } 
    else {  ... }
    
    bug 
    opened by riccardoch 13
  • Signing for

    Signing for "SwiftMessages-SwiftMessages" requires a development team

    I get this error while building with xcode version: 14.0.1. It worked fine with 13.1 version.

    error: Signing for "SwiftMessages-SwiftMessages" requires a development team. Select a development team in the Signing & Capabilities editor. (in target 'SwiftMessages-SwiftMessages' from project 'Pods')

    In my development environment i just removed additional pod "SwiftMessages-SwiftMessages" and it works. But on build server it pulls pod's from cocoapods, so i cannot remove it manually.

    Any advices how to solve it?

    opened by maksirol 1
  • Could not find module 'SwiftMessages' for target 'x86_64-apple-ios-simulator'; found: arm64-apple-ios-simulator, at: Build/Products/Debug-iphonesimulator/SwiftMessages.swiftmodule

    Could not find module 'SwiftMessages' for target 'x86_64-apple-ios-simulator'; found: arm64-apple-ios-simulator, at: Build/Products/Debug-iphonesimulator/SwiftMessages.swiftmodule

    I am getting the following error

    Could not find module 'SwiftMessages' for target 'x86_64-apple-ios-simulator'; found: arm64-apple-ios-simulator, at: Build/Products/Debug-iphonesimulator/SwiftMessages.swiftmodule

    I have opened Xcode 14 in Rosetta Mode on M1 chip and still facing issues when running in the simulator.

    Library version: 9.0.6

    opened by laxmansahni 1
  • Could not find module 'SwiftMessages' for target 'arm64-apple-ios-simulator'; found: x86_64-apple-ios-simulator, at: Build/Products/Debug-iphonesimulator/SwiftMessages.swiftmodule

    Could not find module 'SwiftMessages' for target 'arm64-apple-ios-simulator'; found: x86_64-apple-ios-simulator, at: Build/Products/Debug-iphonesimulator/SwiftMessages.swiftmodule

    I am getting the following error

    Could not find module 'SwiftMessages' for target 'arm64-apple-ios-simulator'; found: x86_64-apple-ios-simulator, at: Build/Products/Debug-iphonesimulator/SwiftMessages.swiftmodule
    

    I have opened Xcode in Rosetta Mode and still facing issues when running in the simulator.

    opened by itsaboutcode 0
  • Add option to preserve status bar space

    Add option to preserve status bar space

    Since iOS 13 it is no longer possible to show a view over the status bar. The workaround for this is to hide the status bar before showing the view (see https://github.com/SwiftKickMobile/SwiftMessages/issues/335).

    The issue with this, is that when hiding the status bar on a device without a notch, the window safe area is updated to reflect this, and the content of the app is moved up.

    This PR aims to solve this by adding a new option, Config.preserveStatusBarSpace, that when set to true takes the previous window safeAreaInsets and applies it to the root view controller before showing the new window, and sets it back when removing the window.

    I decide to set it to false by default to preserve the existing behavior. Let me know if you see any big implications of adding this change that I may have overlooked.

    opened by juanj 0
Releases(9.0.6)
  • 9.0.6(Jan 14, 2022)

    • Add UIView associated type to Event, e.g. willShow(UIView) so that event listeners can inspect the view.
    • Add Event.id: String? property so that event listeners can reason about the view's ID.
    Source code(tar.gz)
    Source code(zip)
  • 9.0.5(Oct 5, 2021)

  • 9.0.4(Sep 17, 2021)

    • #471 Xcode 13 issue - Enum cases with associated values cannot be marked potentially unavailable with '@available'
    • Improve colors for dark mode.
    Source code(tar.gz)
    Source code(zip)
  • 9.0.3(Jun 29, 2021)

    Fixes

    • #467 Lower or equal level window's views disappear upon hide
    • #466 Alert not shown after Biometry check
    • #465 Fix broken Carthage build. The Carthage build was broken due to the iMessageDemo project's use of CocoaPods and the automatically generated SwiftMessages framework scheme created by CocoaPods. The podfile was modified to delete this scheme, but Carthage users may need to run pod install on the iMessagesDemo project, if they have CocoaPods installed, or manually delete the iMessageDemo/Pods/Pods.xcodeproj/xcuserdata folder.
    Source code(tar.gz)
    Source code(zip)
  • 9.0.2(Mar 25, 2021)

  • 9.0.1(Mar 18, 2021)

    Fixes

    • #455 #458 Restore key window after message is interacted with. When a message becomes the key window, such as if the user interacts with the message, iOS does not automatically restore the previous key window when the message is dismissed. SwiftMessages has some logic in WindowViewController to restore the key window. This change makes that logic more robust.
    Source code(tar.gz)
    Source code(zip)
  • 9.0.0(Jan 17, 2021)

    Features

    • #447 Add the ability to show view controller in a new window with SwiftMessagesSegue. This capability is available when using SwiftMessagesSegue programmatically by supplying an instance of WindowViewController as the segue's source view controller.

    Fixes

    • #451 Fix app extension crash

    Changes

    • This release has minor breaking changes in the WindowViewController initializers. The windowLevel is no longer accepted as an argument because the config parameter should specify the window level in the presentationContext property.
    Source code(tar.gz)
    Source code(zip)
  • 8.0.5(Dec 20, 2020)

  • 8.0.4(Dec 15, 2020)

    Features

    • #442 Added MarginAdjustable.respectSafeArea option to exclude safe area from layout margins.
    • #430 Support disable becomeKeyWindow from SwiftMessages.Config. This is a workaround for potential issues with apps that display additional windows.

    Fixes

    • #437 Revert to explicitly specifying "SwiftMessages" as the module in nib files.
    • #440 Fix crash when using SwiftMessages in app extension
    Source code(tar.gz)
    Source code(zip)
  • 8.0.3(Oct 25, 2020)

    Features

    • Full support for Swift Package Manager

    Fixes

    • #328 ignoreDuplicates is not working
    • #412 Fix deployment target on nib files to match target
    Source code(tar.gz)
    Source code(zip)
  • 8.0.2(Aug 18, 2020)

  • 8.0.0(Jul 9, 2020)

    Sorry for taking so long to release this.

    Changes

    • Add SwiftMessages.PresentationContext.windowScene option for targeting a specific window scene.
    • Changed the behavior of the default presentationContext, .automatic. Previously, if the root view controller was presenting, the message would only be displayed over the presented view controller if the modalPresentationStyle was fullScreen or overFullScreen. Now, messages are always displayed over presented view controllers.
    • Made showDuraton and hideDuration on Animator non-optional.
    • Made showDuraton and hideDuration writable options on TopBottomAnimation and PhysicsAnimation.

    Fixes

    • #365 Fix an issue with customized TopBottomAnimation where messages weren't properly displayed under navigation and tab bars.
    • #352 Fix accessibility for view controllers presented with SwiftMessagesSegue.
    • #355 Update card view layout to support centering of pure textual content
    • #354 Support overrideUserInterfaceStyle when view presented in its own window
    • #360 Fix touch handing issue in iOS 13.1.3
    • #382 Fix warnings in Xcode 11.4
    Source code(tar.gz)
    Source code(zip)
  • 7.0.1(Sep 19, 2019)

    Changes

    • Support iOS 13.

    Features

    • #335 Add option to hide status bar when view is displayed in a window. As of iOS 13, windows can no longer cover the status bar. The only alternative is to set Config.prefersStatusBarHidden = true to hide it.
    Source code(tar.gz)
    Source code(zip)
  • 7.0.0(May 23, 2019)

    Changes

    • Swift 5
    • Remove deprecated APIs

    Features

    • #313 Improved sizing on iPad

    SwiftMessagesSegue provides default view controller sizing based on device, with width on iPad being limited to 500pt max. However, it is recommended that you explicitly specify size appropriate for your content using one of the following methods.

    1. Define sufficient width and height constraints in your view controller such that it sizes itself.
    2. Set the preferredContentSize property (a.k.a "Use Preferred Explicit Size" in Interface Builder's attribute inspector). Zeros are ignored, e.g. CGSize(width: 0, height: 350) only affects the height.
    3. Add explicit width and/or height constraints to segue.messageView.backgroundView.

    Note that Layout.topMessage and Layout.bottomMessage are always full screen width. For other layouts, the there is a maximum 500pt width on for regular horizontal size class (iPad) at 950 priority. This limit can be overridden by adding higher-priority constraints.

    • #275 Add ability to avoid the keyboard.

    The KeyboardTrackingView class can be used to cause the message view to avoid the keyboard by sliding up when the keyboard gets too close.

    // Message view
    var config = SwiftMessages.defaultConfig
    config.keyboardTrackingView = KeyboardTrackingView()
    
    // Or view controller
    segue.keyboardTrackingView = KeyboardTrackingView()
    

    You can incorporate KeyboardTrackingView into your app even when you're not using SwiftMessages. Install into your view hierarchy by pinning KeyboardTrackingView to the bottom, leading, and trailing edges of the screen. Then pin the bottom of your content that should avoid the keyboard to the top KeyboardTrackingView. Use an equality constraint to strictly track the keyboard or an inequality constraint to only move when the keyboard gets too close. KeyboardTrackingView works by observing keyboard notifications and adjusting its height to maintain its top edge above the keyboard, thereby pushing your content up. See the comments in KeyboardTrackingView for configuration options.

    • #276 Add ability to hide message without animation
    • #272 Add duration for SwiftMessagesSegue
    • #278 Make pan gesture recognizers public
    Source code(tar.gz)
    Source code(zip)
  • 5.0.1(Sep 3, 2018)

  • 5.0.0(Aug 29, 2018)

    Breaking Changes

    • Removed support for iOS 8.

    Features

    • Add support for modal view controller presentation using SwiftMessagesSegue custom segue subclass. Try it out in the "View Controllers" section of the Demo app. In addition to the class documentation, more can be found in the View Controllers readme.
    • Update nib files to be more visually consistent with iPhone X:
      • Introduce CornerRoundingView, which provides configurable corner rounding using squircles (the smoother method of rounding corners that you see on app icons). Nib files that feature rounded corners have their backgroundView assigned to a CornerRoundingView. CornerRoundingView provides a roundsLeadingCorners option to dynamically round only the leading corners of the view when presented from top or bottom (a feature used for the tab-style layouts).
      • Increased the default corner radius to 20. Corner radius can be changed by either modifying the nib file or
    • Reworked the MarginAdjustable to improve configurability of layout margins.
    • Add rubber-banding to the interactive dismissal gesture. Rubber banding is automatically applied for views where backgroundView is inset from the message view's edges.
    • Added showDuration and hideDuration properties to the Animator protocol (with default implementation that returns nil). These values enable animations to work for view controller presentation.

    Fixes

    • #202 bodyLabel should set textAlignment to .natural
    • #200 Automatic Presentation Context Broken
    • Fix default value of TopBottomAnimation.closePercentThreshold
    Source code(tar.gz)
    Source code(zip)
  • 4.1.4(May 25, 2018)

    Bug Fixes

    • Fix #191 Prevent usage of UIApplication.shared when building for extensions

    Improvements

    • #192 Add a way to test compilation with app extension
    Source code(tar.gz)
    Source code(zip)
  • 4.1.3(May 23, 2018)

    Features

    • #183 Added iOS app extension support at compile time.

    Bug Fixes

    • Fix #185 Incorrect margin adjustments in landscape
    • Fix #188 Physics animation visual glitch
    Source code(tar.gz)
    Source code(zip)
  • 4.1.2(Apr 2, 2018)

    4.1.2

    Features

    • Updates for Swift 4.1
    • #164 Added an optional windowViewController property to SwiftMessages.Config for supplying a custom subclass of WindowViewController.

    Bug Fixes

    • Custom presentation styles using TopBottomAnimation now display properly under top and bottom bars.
    Source code(tar.gz)
    Source code(zip)
  • 4.1.0(Nov 15, 2017)

    Features

    • Fix #134 add support for CenterAnimation displayed on top or bottom instead of center (renamed to PhysicsAnimation).

    Fixes

    • Fix #128 move icons out of asset catalog to prevent mysterious crash
    • Fix #129 adjust layout margins on orientation change to preserve layout when iOS hides status bar in landscape.
    • Fix #131 by always completing hide/show animations if application isn't active.
    Source code(tar.gz)
    Source code(zip)
  • 4.0.0(Sep 21, 2017)

    Features

    • Swift 4.0 syntax

    • Added support for iOS 11 and iPhone X. From the readme:

      SwiftMessages 4 supports iOS 11 out-of-the-box with built-in support for safe areas. To ensur that message view layouts look just right when overlapping safe areas, views that adopt the MarginAdjustable protocol (like MessageView) will have their layout margins automatically adjusted by SwiftMessages. However, there is no one-size-fits-all adjustment, so the following properties were added to MarginAdjustable to allow for additional adjustments to be made to the layout margins:

      public protocol MarginAdjustable {
          ...
          /// Safe area top adjustment in iOS 11+
          var safeAreaTopOffset: CGFloat { get set }
          /// Safe area bottom adjustment in iOS 11+
          var safeAreaBottomOffset: CGFloat { get set }
      }
      

      If you're using using custom nib files or view classes and your layouts don't look quite right, try adjusting the values of these properties. BaseView (the super class of MessageView) declares these properties to be @IBDesignable and you can find sample values in the nib files included with SwiftMessages.

    Bug Fixes

    • Fix #100 memory leak.
    • Change Layout enum capitalization to current Swift conventions.
    Source code(tar.gz)
    Source code(zip)
  • 3.5.1(Sep 12, 2017)

  • 3.5.0(Sep 6, 2017)

    Features

    • Added SwiftMessages.hideCounted(id:) method of hiding. The counted method hides when the number of calls to show() and hideCounted(id:) for a given message ID are equal. This can be useful for messages that may be shown from multiple code paths to ensure that all paths are ready to hide.

      Also added SwiftMessages.count(id:) to get the current count and SwiftMessages.set(id:count:) to set the current count.

    • Added ways to retrieve message views currently being shown, hidden, or queued to be shown.

      // Get a message view with the given ID if it is currently 
      // being shown or hidden.
      if let view = SwiftMessages.current(id: "some id") { ... }
      
      // Get a message view with the given ID if is it currently 
      // queued to be shown. 
      if let view = SwiftMessages.queued(id: "some id") { ... }
      
      // Get a message view with the given ID if it is currently being
      // shown, hidden or in the queue to be shown.
      if let view = SwiftMessages.currentOrQueued(id: "some id") { ... }
      

    Bug Fixes

    • Fix #116 for message views that don't adopt the Identifiable protocol by using the memory address as the ID.
    • Fix #113 MessageView not hiding
    • Fix #87 Support manual install
    Source code(tar.gz)
    Source code(zip)
  • 3.4.0(Jul 1, 2017)

    • Added .center presentation style with a physics-based dismissal gesture.
    • Added .custom(animator:) presentation style, where you provide an instance of the Animator protocol. The TopBottomAnimation and CenterAnimation animations both implement Animator and may be subclassed (configuration options will be added in a future release). You may use the PhysicsPanHandler class to incorporate a physics-based dismissal gesture into any custom animator.
    • Added .centered message view layout with elements centered and arranged vertically.
    • Added configureBackgroundView(width:) and configureBackgroundView(sideMargin:) convenience methods to MessageView.
    Source code(tar.gz)
    Source code(zip)
  • 3.3.2(Mar 27, 2017)

    Improvements

    • MessageView is smarter about including additional accessibility views for cases where you've added accessible elements to the view. Previously only the button was included. Now all views where isAccessibilityElement == true are included.

      Note that all nib files now have isAccessibilityElement == false for titleLabel, bodyLabel and iconLabel (titleLabel and bodyLabel are read out as part of the overall message view's text). If any of these need to be directly accessible, then copy the nib file into your project and select "Enabled" in the Accessibility section of the Identity Inspector.

    Source code(tar.gz)
    Source code(zip)
  • 3.3.1(Mar 13, 2017)

Owner
SwiftKick Mobile
Mobile app design and development agency
SwiftKick Mobile
A smooth, responsive and flexible messages UI library for iOS.

AsyncMessagesViewController A smooth, responsive and flexible messages UI library for iOS apps. Built on top of the awesome Texture (formerly AsyncDis

Huy Nguyen 300 Oct 10, 2022
MQTT for iOS and macOS written with Swift

CocoaMQTT MQTT v3.1.1 client library for iOS/macOS/tvOS written with Swift 5 Build Build with Xcode 11.1 / Swift 5.1 Installation CocoaPods Install us

EMQ X MQTT Broker 1.4k Dec 29, 2022
Messenger Clone - Real-time iOS Chat with Firebase Firestore written in Swift

Real time Swift iOS Chat with Firebase - Messenger Clone This is an extremely simple chat app source code of an iOS Swift Chat app. It leverages Messa

Instamobile 621 Jan 6, 2023
A SlackTextViewController replacement written in Swift for the iPhone X.

Installation Just add MessageViewController to your Podfile and install. Done! pod 'MessageViewController' Setup You must subclass MessageViewControll

GitHawk 1.7k Jan 4, 2023
A fully fledged syscfg editor. Just the editor. Written in pure swift.

MagicCFG Reloaded The SysCFG Writing Utility - UPDATED, OSV Report Bug Table of Contents About MagicCFG Reloaded Getting Started Roadmap Contact Credi

Jan Fabel 47 Dec 31, 2022
Meerkat is a messaging app written using SwiftUI.

Meerkat - A Messaging App Purpose I studied to learn SwiftUI dynamics, understand the syntax, and learn how to integrate third party libraries. The ap

fischerweise 2 Jun 22, 2022
Swift toolkit for passing messages between iOS apps and extensions.

_________ ___ ___ _ _____ _________ ___ ___ / / \ \ / / |_| ( ___ \ \__ __/ \ \ / / / _____/ \ \ /\ /

Abdullah Selek 58 Nov 3, 2022
An XMPP Framework in Objective-C for Mac and iOS

XMPPFramework An XMPP Framework in Objective-C for the Mac and iOS development community. Abstract XMPPFramework provides a core implementation of RFC

Robbie Hanson 5.9k Dec 26, 2022
Open source, native iOS Messenger, with realtime chat conversations (full offline support).

OVERVIEW This is a native iOS Messenger app, with realtime chat conversations (full offline support). NEW FEATURES Passcode support GraphQL server sup

Related Code 4.5k Jan 9, 2023
Chat SDK iOS - Open Source Mobile Messenger

Chat SDK Open Source Messaging framework for iOS Chat SDK is a fully featured open source instant messaging framework for iOS. Chat SDK is fully featu

Chat SDK 879 Jan 6, 2023
Phantom Anonymous Messenger for iOS

?? Phantom for iOS This repository contains the complete source code of Phantom for iOS. Table of Contens ?? Report Bugs/Feature Requests/Security Iss

null 2 Mar 14, 2022
A lightweight framework to build chat applications, made in Swift

Chatto Chatto is a Swift lightweight framework to build chat applications. It's been designed to be extensible and performant. Along with Chatto there

Badoo Tech 4.4k Dec 19, 2022
Swift SDK for Apache Kafka

SwiftKafka A swift implementation of Kafka for producing and consuming from event streams. This works by wrapping the librdkafka C library. Swift vers

Kitura 54 Dec 21, 2022
Red Torch is a very very (very) simple iOS app that allows you to have a red torch using your screen.

RED Torch Red Torch is a very very (very) simple iOS app that allows you to have a red torch using your screen. The App is based on storyboard, so the

Jakub 0 Jan 1, 2022
A message bar for iOS written in Swift.

Dodo, a message bar for iOS / Swift This is a UI widget for showing text messages in iOS apps. It is useful for showing short messages to the user, so

Evgenii Neumerzhitckii 874 Dec 13, 2022
A message bar for iOS written in Swift.

Dodo, a message bar for iOS / Swift This is a UI widget for showing text messages in iOS apps. It is useful for showing short messages to the user, so

Evgenii Neumerzhitckii 874 Dec 13, 2022
A message bar for iOS written in Swift.

Dodo, a message bar for iOS / Swift This is a UI widget for showing text messages in iOS apps. It is useful for showing short messages to the user, so

Evgenii Neumerzhitckii 874 Dec 13, 2022
Swift APIs for SQLite: Type-safe down to the schema. Very, very, fast. Dependency free.

Lighter Lighter is a set of technologies applying code generation to access SQLite3 databases from Swift, e.g. in iOS applications or on the server. L

Lighter.swift 330 Dec 26, 2022
Lightweight dropdown message bar in Swift. It's simple and beautiful.

SwiftyDrop SwiftyDrop is a lightweight pure Swift simple and beautiful dropdown message. Features Easy to use like: Drop.down("Message") Message field

Morita Naoki 691 Nov 20, 2022
Letters animation allows you to click on different letters and accordingly it will animate letters in a cool way. It has a very attractive UI and is very easy to use.

Letters Animation Cool Letters Animation in iOS written in Swift. Preview Table of content :- Description How to add in your project Requirement Licen

MindInventory 31 Oct 4, 2022