diff --git a/Pod/Classes/TSMessage.h b/Pod/Classes/TSMessage.h index d7f0f46e..2bca3fc8 100755 --- a/Pod/Classes/TSMessage.h +++ b/Pod/Classes/TSMessage.h @@ -69,6 +69,9 @@ typedef NS_ENUM(NSInteger,TSMessageNotificationDuration) { /** By setting this delegate it's possible to set a custom offset for the notification view */ @property (nonatomic, assign) id delegate; +/** Whether or not a specified callback function should be executed on timeout instead of just on button tap **/ +@property (nonatomic) BOOL executeCallbackOnTimeout; + + (instancetype)sharedMessage; + (UIViewController *)defaultViewController; diff --git a/Pod/Classes/TSMessage.m b/Pod/Classes/TSMessage.m index 5c4d530b..bd67b813 100755 --- a/Pod/Classes/TSMessage.m +++ b/Pod/Classes/TSMessage.m @@ -327,6 +327,9 @@ + (BOOL)isNavigationBarInNavigationControllerHidden:(UINavigationController *)na - (void)fadeOutNotification:(TSMessageView *)currentView { [self fadeOutNotification:currentView animationFinishedBlock:nil]; + if (self.executeCallbackOnTimeout) { + [currentView executeCallback]; + } } - (void)fadeOutNotification:(TSMessageView *)currentView animationFinishedBlock:(void (^)())animationFinished diff --git a/Pod/Classes/TSMessageView.h b/Pod/Classes/TSMessageView.h index c578e7b2..5c98df9c 100755 --- a/Pod/Classes/TSMessageView.h +++ b/Pod/Classes/TSMessageView.h @@ -62,6 +62,9 @@ canBeDismissedByUser:(BOOL)dismissingEnabled; /** Fades out this notification view */ - (void)fadeMeOut; +/** Executes the callback (called by TSMessage on fadeout) **/ +- (void)executeCallback; + /** Use this method to load a custom design file */ + (void)addNotificationDesignFromFile:(NSString *)file; diff --git a/Pod/Classes/TSMessageView.m b/Pod/Classes/TSMessageView.m index 1a3dbbd0..c0c65fca 100755 --- a/Pod/Classes/TSMessageView.m +++ b/Pod/Classes/TSMessageView.m @@ -477,6 +477,13 @@ - (void)fadeMeOut [[TSMessage sharedMessage] performSelectorOnMainThread:@selector(fadeOutNotification:) withObject:self waitUntilDone:NO]; } +- (void)executeCallback +{ + dispatch_async(dispatch_get_main_queue(), ^{ + if (self.callback) { self.callback(); } + }); +} + - (void)didMoveToWindow { [super didMoveToWindow];