diff --git a/Classes/TSMessage.h b/Classes/TSMessage.h
index 0975f779..2304f85d 100755
--- a/Classes/TSMessage.h
+++ b/Classes/TSMessage.h
@@ -118,6 +118,15 @@ typedef enum {
atPosition:(TSMessageNotificationPosition)messagePosition;
+/** Fades out the currently displayed notification. If another notification is in the queue,
+ the next one will be displayed automatically
+ @return YES if the currently displayed notification could be hidden. NO if no notification
+ was currently displayed.
+ */
++ (BOOL)dismissActiveNotification;
+
+
+
/** Shows a predefined error message, that is displayed, when this action requires an internet connection */
+ (void)showInternetError;
diff --git a/Classes/TSMessage.m b/Classes/TSMessage.m
index bede2cf3..5ce9b2b4 100755
--- a/Classes/TSMessage.m
+++ b/Classes/TSMessage.m
@@ -236,6 +236,8 @@ - (void)fadeInCurrentNotification
{
currentView.center = toPoint;
currentView.alpha = TSMessageViewAlpha;
+ } completion:^(BOOL finished) {
+ currentView.messageIsFullyDisplayed = YES;
}];
@@ -254,6 +256,7 @@ - (void)fadeInCurrentNotification
- (void)fadeOutNotification:(TSMessageView *)currentView
{
+ currentView.messageIsFullyDisplayed = NO;
[NSObject cancelPreviousPerformRequestsWithTarget:self
selector:@selector(fadeOutNotification:)
object:currentView];
@@ -292,6 +295,21 @@ - (void)fadeOutNotification:(TSMessageView *)currentView
}];
}
++ (BOOL)dismissActiveNotification
+{
+ if ([[TSMessage sharedMessage].messages count] == 0) return NO;
+
+ dispatch_async(dispatch_get_main_queue(), ^
+ {
+ TSMessageView *currentMessage = [[TSMessage sharedMessage].messages objectAtIndex:0];
+ if (currentMessage.messageIsFullyDisplayed)
+ {
+ [[TSMessage sharedMessage] fadeOutNotification:currentMessage];
+ }
+ });
+ return YES;
+}
+
#pragma mark class Methods to subclass
+ (UIViewController *)defaultViewController
diff --git a/ExampleProject/Example/TSSecondViewController.h b/ExampleProject/Example/TSSecondViewController.h
index 1f8ad1c5..bd1784e5 100644
--- a/ExampleProject/Example/TSSecondViewController.h
+++ b/ExampleProject/Example/TSSecondViewController.h
@@ -20,5 +20,6 @@
- (IBAction)didTapMessage:(id)sender;
- (IBAction)didTapSuccess:(id)sender;
- (IBAction)didTapButtonidsender:(id)sender;
+- (IBAction)didTapDismissCurrentMessage:(id)sender;
@end
diff --git a/ExampleProject/Example/TSSecondViewController.m b/ExampleProject/Example/TSSecondViewController.m
index 0ca9281c..df591105 100644
--- a/ExampleProject/Example/TSSecondViewController.m
+++ b/ExampleProject/Example/TSSecondViewController.m
@@ -116,4 +116,9 @@ - (IBAction)didTapButtonidsender:(id)sender
atPosition:self.onBottomToggle.on];
}
+- (IBAction)didTapDismissCurrentMessage:(id)sender
+{
+ [TSMessage dismissActiveNotification];
+}
+
@end
diff --git a/ExampleProject/Example/en.lproj/MainStoryboard.storyboard b/ExampleProject/Example/en.lproj/MainStoryboard.storyboard
index 454236ec..020c3559 100644
--- a/ExampleProject/Example/en.lproj/MainStoryboard.storyboard
+++ b/ExampleProject/Example/en.lproj/MainStoryboard.storyboard
@@ -80,6 +80,19 @@
+