• Stars
    star
    4,874
  • Rank 8,616 (Top 0.2 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created over 11 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿ’Œ Easy to use and customizable messages/notifications for iOS ร  la Tweetbot

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)

Screenshots

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.

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.

More Repositories

1

detect.location

An easy way to access the user's iOS location data without actually having access
Objective-C
1,244
star
2

FxLifeSheet

Tracking the key metrics of my life
Ruby
1,066
star
3

what-terminal-is-felix-using

๐Ÿ’ป For everyone who wants to know more about the terminal I use
511
star
4

overkill-for-mac

Stop iTunes from opening when you connect your iPhone
Swift
506
star
5

overkill

Don't let iTunes interrupt your workflow ๐Ÿ’ฅ๐ŸŽต
Ruby
482
star
6

InAppBrowser.com

Showcasing what in-app browsers do under the hood
HTML
470
star
7

WiFiAuth

Because connecting to WiFis is still an unsolved problem ๐Ÿ˜‚
Objective-C
424
star
8

mood

Keeping track of current level of happiness
Ruby
353
star
9

steal.password

Easily get the user's Apple ID password, just by asking
330
star
10

watch.user

Every iOS app you ever gave permission to use your camera can record you any time it runs - without notice
Swift
287
star
11

markdown-to-html-github-style

Generate a simple HTML page based on a markdown file, that looks like GitHub's stylesheet
HTML
226
star
12

MajorKey

The fastest iOS app to add a note to your email inbox
Swift
186
star
13

new-mac

List of the things to do on a new Mac
Ruby
181
star
14

notes-exporter

Because GPDR exists for a reason, oh hi Apple
Ruby
164
star
15

krausefx.com

My personal blog
HTML
162
star
16

instapipe

Automatically cross-post your Instagram stories
Ruby
156
star
17

twitter-unfollow

Unfollow everybody on Twitter
Ruby
144
star
18

whereisfelix.today-backend

Yes, that's a thing
JavaScript
128
star
19

howisFelix.today

Yes, that's a thing
HTML
109
star
20

dotfiles

Learning the difference between > and >>
Shell
85
star
21

fastrockets

Visualize fastlane launches as rockets
Ruby
25
star
22

speaking

Upcoming and past speaking engagements
23
star
23

fastlane-ascii-art

๐Ÿƒ Add some fun to your fastlane output.
Ruby
22
star
24

auxcord.org

Have a Sonos system, and are hosting a party? Let's gooo
Ruby
21
star
25

CoreMLDemo

The demo project containing all source code from the ContextSDK blog post series
Swift
21
star
26

evaluation_report

The evaluation report I wrote about fastlane at university
19
star
27

trollol

GitHub pull requests - done right
14
star
28

fastlane-plugin-load_json

Loads a local JSON file and parses it
Ruby
14
star
29

Three20.swift

Three20 is a Swift library for iOS developers
11
star
30

rScreenshooter

Helps you create screenshots in multiple languages on different device types using UIAutomation.
Ruby
11
star
31

privacy-share-button

Proof of concept: detect when an iOS user hits the share button on your website
HTML
11
star
32

fastlane-plugin-clubmate

Print the Club Mate logo in your build output
Ruby
10
star
33

brewfile

Some of the brews I use
Ruby
9
star
34

trips

My upcoming trips
Ruby
9
star
35

fastlane-tunes

๐ŸŽถ Play music using fastlane, because you can.
Ruby
9
star
36

telegram-advent-calendar

A simple to use Telegram Advent Calendar
Ruby
8
star
37

fastlane-plugin-ya_tu_sabes

Ya tu sabes.
Ruby
8
star
38

felix.fitness

Public fitness dashboard
7
star
39

certs

Certificates for [email protected] certs
7
star
40

tweet_collection_manager

Managing all the tweets, like a management manager
Ruby
6
star
41

fastlane-plugin-no_u

no u
Ruby
6
star
42

wealthfront-tax-info-exporter

Export all transactions (including dividends) details into a CSV file
Ruby
5
star
43

light-phone-note-to-self

A simple script to fetch the most recent Notes from your Light Phone and send them to yourself via Email
Ruby
5
star
44

doesitrain.today

Ruby
5
star
45

resume

About me
5
star
46

engagement-enhancer

Not hitting your OKRs? Not getting enough engagement? Fix it with one little trick
HTML
4
star
47

krausefx-gem

Ruby
4
star
48

set-times

A collection of set-times for various venues
HTML
4
star
49

bot

@seriouskrausefx
Ruby
4
star
50

walkwithfriends

Stay in touch with close friends around the world
Ruby
3
star
51

gwg

Geringwertige Wirtschaftsgรผter finden
CSS
2
star
52

license_checker

Ruby
2
star
53

whichsideoftheriver.in

HTML
1
star