💌 Easy to use and customizable messages/notifications for iOS à la Tweetbot

Overview

Notice: TSMessages is no longer being maintained/updated. We recommend everyone migrate to RMessage.

This repository will be kept as is for those who want to continue using TSMessages or are in the process of migrating. If an issue you submitted to TSMessages still applies to RMessage feel free to create a new issue in RMessage's repository.

If your project is Swift based, you might want to check out SwiftMessages, which offers the same features, but is written completely in Swift.

TSMessages

This library provides an easy to use class to show little notification views on the top of the screen. (à la Tweetbot).

Twitter: @KauseFx Version License Platform

The notification moves from the top of the screen underneath the navigation bar and stays there for a few seconds, depending on the length of the displayed text. To dismiss a notification before the time runs out, the user can swipe it to the top or just tap it.

There are 4 different types already set up for you: Success, Error, Warning, Message (take a look at the screenshots)

It is very easy to add new notification types with a different design. Add the new type to the notificationType enum, add the needed design properties to the configuration file and set the name of the theme (used in the config file and images) in TSMessagesView.m inside the switch case.

Take a look at the Example project to see how to use this library. You have to open the workspace, not the project file, since the Example project uses cocoapods.

Get in contact with the developer on Twitter: KrauseFx (Felix Krause)

Installation

From CocoaPods

TSMessages is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "TSMessages"

Manually

Copy the source files TSMessageView and TSMessage into your project. Also copy the TSMessagesDesignDefault.json.

Usage

To show notifications use the following code:

    [TSMessage showNotificationWithTitle:@"Your Title"
                                subtitle:@"A description"
                                    type:TSMessageNotificationTypeError];


    // Add a button inside the message
    [TSMessage showNotificationInViewController:self
                                          title:@"Update available"
                                       subtitle:@"Please update the app"
                                          image:nil
                                           type:TSMessageNotificationTypeMessage
                                       duration:TSMessageNotificationDurationAutomatic
                                       callback:nil
                                    buttonTitle:@"Update"
                                 buttonCallback:^{
                                     NSLog(@"User tapped the button");
                                 }
                                     atPosition:TSMessageNotificationPositionTop
                           canBeDismissedByUser:YES];


    // Use a custom design file
    [TSMessage addCustomDesignFromFileWithName:@"AlternativeDesign.json"];

You can define a default view controller in which the notifications should be displayed:

   [TSMessage setDefaultViewController:myNavController];

You can define a default view controller in which the notifications should be displayed:

   [TSMessage setDelegate:self];
   
   ...
   
   - (CGFloat)messageLocationOfMessageView:(TSMessageView *)messageView
   {
    return messageView.viewController...; // any calculation here
   }

You can customize a message view, right before it's displayed, like setting an alpha value, or adding a custom subview

   [TSMessage setDelegate:self];
   
   ...
   
   - (void)customizeMessageView:(TSMessageView *)messageView
   {
      messageView.alpha = 0.4;
      [messageView addSubview:...];
   }

You can customize message view elements using UIAppearance

#import <TSMessages/TSMessageView.h>
@implementation TSAppDelegate
....

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//If you want you can overidde some properties using UIAppearance
[[TSMessageView appearance] setTitleFont:[UIFont boldSystemFontOfSize:6]];
[[TSMessageView appearance] setTitleTextColor:[UIColor redColor]];
[[TSMessageView appearance] setContentFont:[UIFont boldSystemFontOfSize:10]];
[[TSMessageView appearance]setContentTextColor:[UIColor greenColor]];
[[TSMessageView appearance]setErrorIcon:[UIImage imageNamed:@"NotificationButtonBackground"]];
[[TSMessageView appearance]setSuccessIcon:[UIImage imageNamed:@"NotificationButtonBackground"]];
[[TSMessageView appearance]setMessageIcon:[UIImage imageNamed:@"NotificationButtonBackground"]];
[[TSMessageView appearance]setWarningIcon:[UIImage imageNamed:@"NotificationButtonBackground"]];
//End of override

return YES;
}

The following properties can be set when creating a new notification:

  • viewController: The view controller to show the notification in. This might be the navigation controller.
  • title: The title of the notification view
  • subtitle: The text that is displayed underneath the title (optional)
  • image: A custom icon image that is used instead of the default one (optional)
  • type: The notification type (Message, Warning, Error, Success)
  • duration: The duration the notification should be displayed
  • callback: The block that should be executed, when the user dismissed the message by tapping on it or swiping it to the top.

Except the title and the notification type, all of the listed values are optional

If you don't want a detailed description (the text underneath the title) you don't need to set one. The notification will automatically resize itself properly.

Screenshots

iOS 7 Design

iOS 7 Error

iOS 7 Message

iOS 6 Design

Warning

Success

Error

Message

License

TSMessages is available under the MIT license. See the LICENSE file for more information.

Recent Changes

Can be found in the releases section of this repo.

Comments
  • TSMessage over the navigation bar?

    TSMessage over the navigation bar?

    I'm on iOS7 and my TSMessage always shows beneath the NavigationBar, Is there any way to make it "cover" the navigation bar and status bar?

    I'm using the following code:

    [TSMessage showNotificationInViewController:self.navigationController
                                                  title:@"Test test"
                                               subtitle:@"This is a tester"
                                                  image:nil type:TSMessageNotificationTypeSuccess
                                               duration:1.0
                                               callback:nil
                                            buttonTitle:nil
                                         buttonCallback:nil
                                             atPosition:TSMessageNotificationPositionTop
                                   canBeDismissedByUser:YES];
    
    opened by freak4pc 17
  • Different behaviours in iOS 6 & iOS7

    Different behaviours in iOS 6 & iOS7

    I am showing TSMessage in view controller pushed in UINavigationController. I am showing TSMessage using below code -(void)showPopUpFromBottomWithTitle:(NSString_)title andMessage:(NSString_)message { [TSMessage showNotificationInViewController:self title:title subtitle:message image:nil type:TSMessageNotificationTypeSuccess duration:15 callback:nil buttonTitle:nil buttonCallback:nil atPosition:TSMessageNotificationPositionTop canBeDismisedByUser:YES]; }

    But I am getting different behaviours in iOS 6 & iOS7 as shown below

    1. Why I am getting space between bottom of screen & alert if position is bottom ?
    2. Why can't I see background color (green) in case of iOS7 ?

    iOS 6 top ios6_top iOS 6 bottom ios6_bottom

    iOS7 top ios7_top

    iOS7 bottom ios7_bottom

    opened by nfs3250 15
  • TSMessage shows under navigation bar

    TSMessage shows under navigation bar

    My ViewController is embedded in UINavigationController. But I have made navigation bar hidden.

    Whenever I call [TSMessage showNotificationInViewController:self title:@"Network Error" subtitle:@"Couldn't connect to the server. Check your network connection" type:TSMessageNotificationTypeError];

    ios simulator screen shot 24-feb-2014 11 23 41 am copy

    It moves TSMessage 64pts down. I want to display it at 0 verticalOffset.

    I have found in TSMessage.m if ([currentView.viewController isKindOfClass:[UINavigationController class]] || [currentView.viewController.parentViewController isKindOfClass:[UINavigationController class]]) {

    Is always executed, whether I have navigationBar hidden or shown.

    I also have tried calling showNotificationInViewController with self self.navigationController self.parentViewController

    All above gives the same result

    opened by khawarshzd 14
  • Few errors after update

    Few errors after update

    Hi, I just updated the code to get some of the new features and this is what I got:

    [self.toolbar setBarTintColor:blurTintColor];
    

    the compiles show message: "No visible @interface for 'UIToolbar' declares the selector 'setBarTintColor' "

    Also it cannot find the HexColor.h in the project

    bug 
    opened by cytryn 12
  • Managing global notification in case of a Tab Bar Controller

    Managing global notification in case of a Tab Bar Controller

    I have a tab bar controller with multiple navigation controllers on each tab. It shows up on one navigation controller, but when I switch a tab, it doesn't. Any suggestions on how to go about this?

    question 
    opened by abheyrajbsb 11
  • textField becomeFirstResponder issue

    textField becomeFirstResponder issue

    As far as I know, I am not doing anything wrong here. What I want if to verify a textField, so if a user tries to add something that wont validade, I show the message by doing this:

            [TSMessage showNotificationInViewController:self
                                                  title:@"Title"
                                               subtitle:@"Something went wrong!"
                                                  image:nil
                                                   type:TSMessageNotificationTypeWarning
                                               duration:TSMessageNotificationDurationAutomatic
                                               callback:^{
                                                   [tabTextField becomeFirstResponder];
                                               }
                                            buttonTitle:nil
                                         buttonCallback:nil
                                             atPosition:TSMessageNotificationPositionTop
                                    canBeDismisedByUser:YES];
    

    The thing is that I added a callback so when the user hits the warning, he automatically goes to the textField that needs to be changed.

    But when this happen, they keyboard goes up, then the warning goes off, then it ajusts the screen. So when I hit the 'done' button it shifts the whole view down again!

    I dont know if I made myself clear but here is a short video showing whats happening: http://screencast.com/t/IkzexWp0

    opened by cytryn 11
  • Not limited duration

    Not limited duration

    Sometimes it's interesting that the message stays in the screen until a new message is thrown. For example, I'm thinking in detectecting network reachability, when the network is down I would like to show an error message and that the error stays until I detect that the network is up again, then I will show a success message (this one with a limited duration), and this new message makes the previous one dissapear.

    What do you think?

    feature 
    opened by brooly 11
  • Accept UIAppearance

    Accept UIAppearance

    Added capacity to customize layout using UIAppearance Now you have one alternative to customize TSMessageView, you can use UIAppearance. These are the properties

    [TSMessageView appearance] setTitleFont:[UIFont boldSystemFontOfSize:6]];
    [[TSMessageView appearance] setTitleTextColor:[UIColor redColor]];
    [[TSMessageView appearance] setContentFont:[UIFont boldSystemFontOfSize:10]];
    [[TSMessageView appearance]setContentTextColor:[UIColor greenColor]];
    [[TSMessageView appearance]setErrorIcon:[UIImage imageNamed:@"NotificationButtonBackground"]];
    [[TSMessageView appearance]setSuccessIcon:[UIImage imageNamed:@"NotificationButtonBackground"]];
    [[TSMessageView appearance]setMessageIcon:[UIImage imageNamed:@"NotificationButtonBackground"]];
    [[TSMessageView appearance]setWarningIcon:[UIImage imageNamed:@"NotificationButtonBackground"]];
    
    opened by diogomaximo 10
  • [TSMessage addCustomDesignFromFileWithName:@

    [TSMessage addCustomDesignFromFileWithName:@"AlternativeDesign.json"] crashes

    after the recent changes [TSMessage addCustomDesignFromFileWithName:@"AlternativeDesign.json"] crashes when using a custom design.

    this is due to the fact that the json file is looked up only inside the new bundle. specifically, this line causes the crash: https://github.com/toursprung/TSMessages/commit/5908e4ca00d5f0397549a18f9ff4d6502294c66d#diff-66f9603ce433cc6cc7b4df87530f4b9bR76

    opened by aporat 10
  • HexColor.h - Missing

    HexColor.h - Missing

    When building for iOS6 in XCode 4.3 you get a runtime crash as HexColor.h is not in the project.

    This will be because I'm not using Cocopods...

    (Was UIColor+ColorWithHex).

    The crash +[UIColor colorWithHexString:alpha:]: unrecognized selector sent to class 0x3bbbefc0 -[TSMessageView initWithTitle:subtitle:image:type:duration:inViewController:callback:buttonTitle:buttonCallback:atPosition:shouldBeDismissed:] in TSMessageView.m on Line 168

    opened by al-little 10
  • Position at bottom?

    Position at bottom?

    I love this repo, compliments on your hard work. Is it possible to position TSMessages at the bottom of a controller? If not, please add this request as an enhancement. Thank you.

    opened by forward6 10
  • Podspec for 0.9.13 missing?

    Podspec for 0.9.13 missing?

    It appears that the pod spec for v.0.9.13 are missing from the cocoapods site: https://github.com/CocoaPods/Specs/blob/master/Specs/a/5/3/TSMessages/0.9.13/TSMessages.podspec.json

    We did a pod repo update, but still got errors while trying to update the pod.: pod 'TSMessages' ,'0.9.13'

    [!] CocoaPods could not find compatible versions for pod "TSMessages":
      In Podfile:
        TSMessages (= 0.9.13)
    
    None of your spec sources contain a spec satisfying the dependency: `TSMessages (= 0.9.13)`.
    

    Hope you can sort it out :-)

    opened by pwschulz 0
  • [!] Unable to find a specification for `TSMessage (~> 0.9.13)`

    [!] Unable to find a specification for `TSMessage (~> 0.9.13)`

    [!] Unable to satisfy the following requirements:

    • TSMessages (~> 0.9.13) required by Podfile

    None of your spec sources contain a spec satisfying the dependency: TSMessages (~> 0.9.13).

    You have either:

    • out-of-date source repos which you can update with pod repo update.
    • mistyped the name or version.
    • not added the source repo that hosts the Podspec to your Podfile.

    Note: as of CocoaPods 1.0, pod repo update does not happen on pod install by default.

    opened by semnyqu 1
  • TSMessages incorrect behaviour while installing via framework.

    TSMessages incorrect behaviour while installing via framework.

    Hey,

    Pretty simple example crashed app. [NSBundle mainBundle] doesn't work if library installed as framework. [NSBundle bundleForClass:self.class] could solve problem.

    opened by lolgear 1
Releases(0.9.12)
Owner
Felix Krause
Professional iOS Code Signing Issue Resolver - Developer of @fastlane (previously @google @twitter)
Felix Krause
A simple style messages/notifications, in Swift.

Demo Example To show notifications use the following code: self.showMessage("Something success", type: .success) To display a notice on a view: view.s

Gesen 704 Dec 17, 2022
[iOS] Easy, customizable notifications displayed on top of the statusbar. With progress and activity. iPhone X ready.

JDStatusBarNotification Show messages on top of the status bar. Customizable colors, font and animation. Supports progress display and can show an act

M Emrich 3.8k Dec 27, 2022
SwiftOverlays is a Swift GUI library for displaying various popups and notifications

SwiftOverlays is a Swift GUI library for displaying various popups and notifications. SwiftOverlays animated logo is kindly made by Crafted Pixels Fea

Peter Prokop 632 Dec 22, 2022
A Swift extension that adds toast notifications to the UIView object class.

Toast-Swift Toast-Swift is a Swift extension that adds toast notifications to the UIView object class. It is intended to be simple, lightweight, and e

Charles Scalesse 3.3k Dec 22, 2022
Simple Swift in-app notifications

LNRSimpleNotifications TSMessages is an amazingly powerful in-app notifications library but requires a lot of setup. LNRSimpleNotifications is a simpl

LISNR 203 Nov 20, 2022
CoffeeToast - A swift package to easily add Toast notifications to your app

CoffeeToast A simple Swift package to add Toast Notifications to your app. Insta

Maegan Wilson 2 Feb 3, 2022
An easy to use UIAlertController builder for swift

LKAlertController An easy to use UIAlertController builder for swift Features Short and simple syntax for creating both Alerts and ActionSheets from U

Lightning Kite 97 Feb 8, 2022
Highly customizable alertview and alert/notification/success/error/alarm popup written in Swift

CDAlertView is highly customizable alert popup written in Swift. Usage is similar to UIAlertController. Screenshots Animations Usage Basic usage witho

Candost Dagdeviren 1.1k Dec 30, 2022
PMAlertController is a great and customizable alert that can substitute UIAlertController

PMAlertController is a small library that allows you to substitute Apple's uncustomizable UIAlertController, with a beautiful and totally customizable

Paolo Musolino 2.5k Jan 3, 2023
Fully customizable and extensible action sheet controller written in Swift

XLActionController By XMARTLABS. XLActionController is an extensible library to quickly create any custom action sheet controller. Examples The action

xmartlabs 3.3k Dec 31, 2022
PMAlertController is a great and customizable alert that can substitute UIAlertController

PMAlertController is a small library that allows you to substitute Apple's uncustomizable UIAlertController, with a beautiful and totally customizable

Paolo Musolino 2.5k Jan 3, 2023
Customizable simple Alert and simple ActionSheet for Swift

SimpleAlert It is simple and easily customizable alert. Can be used as UIAlertController. Appetize's Demo Requirements Swift 5.0 iOS 9.0 or later How

Kyohei Ito 397 Dec 6, 2022
In-app notification in Swift, with customizable buttons and input text field.

Notie Undistracted in-app notification in Swift, with added buttons and input box. Installation CocoaPods To integrate Notie into your Xcode project u

Thi Doãn 85 Aug 8, 2020
The easiest way to display highly customizable in app notification banners in iOS

Written in Swift 5 NotificationBanner is an extremely customizable and lightweight library that makes the task of displaying in app notification banne

Dalton Hinterscher 4.5k Jan 9, 2023
A simple, customizable popup dialog for iOS written in Swift. Replaces UIAlertController alert style.

Introduction Popup Dialog is a simple, customizable popup dialog written in Swift. Features Easy to use API with hardly any boilerplate code Convenien

Orderella Ltd. 3.8k Dec 20, 2022
A customizable, full-feature, lightweight iOS framework to be used instead of UIAlertController.

A customizable, full-feature, lightweight iOS framework to be used instead of UIAlertController.

Ali Samaiee 11 Jun 6, 2022
FCAlertView is a Flat Customizable AlertView for iOS (Written in Objective C)

FCAlertView FCAlertView is a Flat Customizable AlertView, written in Objective C Quick Links 1. Swift 2. Installation 3. Example App 4. Adding FCAlert

Nima Tahami 794 Nov 29, 2022
FCAlertView is a Flat Customizable AlertView for iOS (Swift)

FCAlertView FCAlertView is a Flat Customizable AlertView, written in Swift [![CI Status](http://img.shields.io/travis/Nima Tahami/FCAlertView.svg?styl

Kris Penney 114 Apr 19, 2022
Customizable Dynamic Bottom Sheet Library for iOS

DynamicBottomSheet Powerd by Witi Corp., Seoul, South Korea. Fully Customizable Dynamic Bottom Sheet Library for iOS. This library doesn't support sto

Witi Official 10 May 7, 2022