krausefx / tsmessages Goto Github PK
View Code? Open in Web Editor NEW๐ Easy to use and customizable messages/notifications for iOS ร la Tweetbot
Home Page: http://krausefx.com
License: MIT License
๐ Easy to use and customizable messages/notifications for iOS ร la Tweetbot
Home Page: http://krausefx.com
License: MIT License
I currently have a navigation-based app with a modal view controller that allows users to add an event to their calendar. In the block where I check if the app has permission or not, I would love to display an error TSMessage if it has no permission. However, when I click the button the TSMessage is never triggered, yet my ns logs shows that the button is working.
This is how my storyboard is set up:
Here's my code:
EKEventStore *eventStore = [[EKEventStore alloc] init];
if([eventStore respondsToSelector: @selector(requestAccessToEntityType:completion:)]) {
[eventStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL permissionGranted, NSError *error) {
if (permissionGranted){
NSLog(@"PERMISSION GRANTED.");
[self performSelectorOnMainThread:@selector(presentEventEditViewControllerWithEventStore:) withObject:eventStore waitUntilDone:NO];
}
else {
NSLog(@"NO PERMISSION.");
[TSMessage showNotificationInViewController:self
withTitle:@"Error: Permission Required"
withMessage:@"Oops! In order to use this feature, The app needs permission to access your calendars. Please update your privacy settings."
withType:TSMessageNotificationTypeError];
}
}];
}
Any help would be greatly appreciated. PS When I just drop it into my viewDidLoad it loads perfectly fine, am I doing something wrong? Thank you. Do I only need to import "TSMessages.h"? I'm using cocoapods. Thanks.
an additional parameter "fontName" would be nice
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
TSBlurView uses features which are only available in iOS 7 and later.
Hi,
If we show notification on a controller that has scrollbar, it will show on the top of the view instead on the top of the viewport.
Let's say if we have a long form that exceed the viewport (scrollbar shown) and the submit button on the bottom of the form, when user tap submit, the show notification won't be shown to the user since it's viewport origin y not zero anymore.
Hope you understand what i mean.
If you implement this, please make sure, when the user scroll (ex: scroll to the top) the notification will also follow the viewport (so it's stays on the top of the viewport even though the scroll happened and viewport frame changed).
Thank you
Hello, sorry for my english. It would be nice if alert object had a tag to support something like dismissNotificationWithTag: (remove from queue if not displayed yet)
On TSMessageView.m
@property (nonatomic, strong) NSString *title;
@property (nonatomic, strong) NSString *content;
@property (nonatomic, strong) UIViewController *viewController;
Got warning 'property attribute in continuation class does not match primary class'
Looks like because the variable implemented differently with the header file.
TSMessageView.h
@property (nonatomic, readonly) NSString *title;
....
The fix could be change the implementation file to
@property (nonatomic, readwrite) NSString *title;
@property (nonatomic, readwrite) NSString *content;
@property (nonatomic, readwrite) UIViewController *viewController;
But i don't know if this could be stable or not. (Haven't really test it)
Thank you
Is it possible to have a block that is call when the message is gone ? Cause there is CallBack which is call only when the user dismissed the message by tapping on it or swiping it to the top. Do you think that we can also have a method like [TSMessage hide...]; in order to hide that actual message ? Anyway, great job ! thank you
Am getting a error in the PodSpec file when i update TSmessage using the following syntax (fetch most recent version):
pod 'TSMessages', :git => 'https://github.com/toursprung/TSMessages.git'
[!] Invalid TSMessages.podspec
file: compile error
/TSMessages.podspec:17: syntax error, unexpected ':', expecting '}'
...m/toursprung/TSMessages.git" :tag => "#{spec.version}"}
^
/TSMessages.podspec:17: syntax error, unexpected '}', expecting kEND. Updating CocoaPods might fix the issue.
I have a modal view controller, with an added navigation bar. I'm trying to get TSMessages to show up beneath the navigation bar but it keeps displaying on top of it.
Hi all,
On Ipad (maybe also on Iphone) when I add consecutively two TSMessage in landscape orientation, if there is a portrait orientation change before the second TSMessage appears, the second TSMessage animation will start at the wrong position (the landscape position).
I think we should add a method for updating the TSMessageView frame before it appears when the positioning mode is TSMessageNotificationPositionBottom.
This issue appear with the last commit ef45252 when I add the TSMessage to a UINavigationController.
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
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.
Hi i am the creator of the MLUIColorAdditions which are used in this Project and i bumped the Version to 2.0 and renamed it to HexColors.
What about linking the Podspec directly to it. For drop in support you could link it with a sub-module.
If you are interested in this i will go for it and create a pull request.
Hi Felix,
on calling +showNotificationInViewController:withTitle:withMessage:withType:withDuration:withCallback:
and setting a callback block, the message will dismiss after the specified duration, but the callback block is never executed.
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?
When I invoke the following code it throws the error saying "data parameter is nil".
[TSMessage showNotificationInViewController:self
withTitle:@"Success"
withMessage:@"Payment has been recorded!"
withType:TSMessageNotificationTypeSuccess];
Hi,
Just pulled down the latest source and got the following warning.
XCode: 4.6.3 -> Target: iOS 6.0
//TSMessages/Views/TSMessageView.m:278:33: Assigning to 'id' from incompatible type 'TSMessageView *__strong'
Thanks,
Al
Fix:
UITapGestureRecognizer *tapRec = [[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(fadeMeOut)];
tapRec.delegate = self;
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
if ([touch.view isKindOfClass:[UIButton class]])
{
// we touched our control surface
return NO; // ignore the touch
}
return YES; // handle the touch
}
See http://stackoverflow.com/questions/3344341/uibutton-inside-a-view-that-has-a-uitapgesturerecognizer
Is it possible to make the notification float on top of a tableview? So that when the user scrolls down the notification is still visible? Thanks!
The TSMessages are really great in iOS 7 i think. But we should do something complete new in styling the messages. Something with red and a blur would be very nice to match the style of iOS 7.
Whats your point of view on this?
I am using TSMessages to show a notification when the network connection is lost.
The notification is being added to a Navigation Controller (that has a nav Bar) and holds a table view.
What I would like to do is change the contentInset of the tableview, when the Notification is shown. Is there a way I can access the height of the displayed Notification (or notifications if multiple are shown) ?
Secondly, is there a way to get a reference to what notification is being shown. For example, if I show one as a note to the user and one as a warning I need to determine when the warning one is being shown. I cannot check against title as I am using localisation so the title string would be different depending on the language.
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
i need to show a push notification at the currently opened view.
showNotificationInViewController/showNotificationWithTitle(it uses a default view) requires a view parameter. Is there way to find an active view or to develop the control not to be depends to a view?
thanks,
How do I enable the iOS 7 appearance as illustrated in the README? My iOS 7 project still has the old appearance.
Hello, I noticed some compiler warnings:
/Pods/TSMessages/TSMessages/Views/TSBlurView.m:43:47: Undeclared selector 'barTintColor:'
/Pods/TSMessages/TSMessages/Views/TSMessageView.m:437:61: Undeclared selector 'fadeOutNotification:'
btw Xcode 5
Hello,
It's possible to make the tsmessage to stay on top while scrolling a UITableView?
Thanks!
Hi,
There doesn't seem to be any simple way to customize either the design.json file, or the notificationDictionary in a maintainable way when importing TSMessages as a cocoapod, or am I missing something?
The podspec includes the design.json file in the Pods project, and there doesn't seem to be an easy way to override that by the project using the pod. TSDesignFileName is a local define, and notificationDictionary is a local static in TSMessageView.m, so also no easy way to override by a subclass or otherwise.
Please let me know if there is an easier way to customize the design dictionary. My next option is to fork TSMessages and submit a pull request that implements this for your consideration.
Thanks for all your work on TSMessages, I find it very useful.
Hey Dude,
BACKGROUND:
My friend just showed me this project. I haven't played around with it yet, but from the images in the README I have a question.
During a recent project I implemented a pull-tab right under the navigation bar, or header bar, similar kinda similar to yours.
QUESTION:
Did you have problems with folks pulling down iOS Notifications instead of your pull-tab?
-Tobias
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
i tried the following example https://gist.github.com/anonymous/5715510, and I'm wondering if there are any tricks to subclassing this since the methods are static ? It does not call the sublcassed method but always the TSMessage static method. Have you actually gotten this to work ?
Hi,
for some reason, the TSMessageView is shown behind my UINavigationBar on iOS 7.
[TSMessage setDefaultViewController:self];
[TSMessage showNotificationWithTitle:@"Please select a player in the list." type:TSMessageNotificationTypeMessage];
I've also noticed that running the example project on iOS7 simulator does not show the iOS7 style message as in the readme file
What did I do wrong ?
cheers
Currently the initializers are not implemented well: the word 'with' can be removed and the methods are too long.
The new way to init TSMessages should be
// Easy notifications
[TSMessage showNotificationWithTitle:@"" subTitle:@"" type:currentType];
// Advanced notifications
TSMessageView *messageView = [TSMessages messageViewWithTitle:@"" subTitle:@"" type:currentType];
messageView.position = ....; // optional
messageView.duration = 12; // optional
messageView.buttonTitle = @"Update"; //optional
...
// Show the notification
[TSMessages showNotification:messageView];
// or
[TSMessages showNotification:messageView inViewController:vc];
When shouldBeDismissed
is set NO, should we dismiss when button is tapped?
I think we should let buttonCallback decide to dismiss or not.
- (void)buttonTapped:(id) sender
{
if (self.buttonCallback)
{
self.buttonCallback();
}
if (!shouldBeDismiss) {
[self fadeMeOut];
}
}
The buttonCallback
doesn't get called on iOS 5 when I tap the button. Instead, callback
gets called. I also tried it on iOS 6, doesn't have this issue. Any ideas?
+ (void)showNotificationInViewController:(UIViewController *)viewController
withTitle:(NSString *)title
withMessage:(NSString *)message
withType:(TSMessageNotificationType)type
withDuration:(NSTimeInterval)duration
withCallback:(void (^)())callback
withButtonTitle:(NSString *)buttonTitle
withButtonCallback:(void (^)())buttonCallback
atPosition:(TSMessageNotificationPosition)messagePosition
canBeDismisedByUser:(BOOL)dismissingEnabled;
One solution would be to listen to UIKeyboardWillShowNotification/UIKeyboardWillHideNotification and adjust the frame accordingly.
I'm using TSMessages and have my project set to treat warnings as errors for Archive builds. There's an undeclared selector warning that comes up for fadeOutNotification: since that is added to the interface for TSMessage in TSMessage.m instead of TSMessage.h. Is there a reason it couldn't be added to TSMessage.h instead? I guess you want it to be a "private" method?
Here's what I get when building. For
/Users/mangtronix/Dropbox/Work/Changemakrs-mang/changemakrs-ios/Changemakrs/Externals/TSMessages/Views/TSMessageView.m:363:53: error: undeclared selector 'fadeOutNotification:' [-Werror,-Wundeclared-selector]
[[TSMessage sharedMessage] performSelector:@selector(fadeOutNotification:)
I could submit a patch for creating the fadeOutNotification: selector from a string, which would avoid the warning.
It would be great if there was a completion block available to know the a user taps the notification. That way, you could have the user tap it to say, refresh a network connection if there was an error.
Hi,
I'm not sure what I'm doing wrong but my TSMessage has a vertical offset and is not situated just under the navigation bar as I would expect.
// hide iOS 6 refresh control
[self.refreshControl endRefreshing];
dispatch_async(dispatch_get_main_queue(), ^{
[TSMessage showNotificationInViewController:self.navigationController
withTitle:message
withMessage:nil
withType:type
withDuration:5.0];
});
What could be the reason?
I have seen a crash occur a number of times on the removeObjectAtIndex
NSMutableArray method called in fadeOutNotification
.
It seems only to crash when there is more than one TSMessage queued to be shown on screen. It may happen when I tap a notification to dismiss it while it is already fading out.
Here is an example crash log showing this.
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.