TSMessages icon indicating copy to clipboard operation
TSMessages copied to clipboard

Tap doesn't dismiss the message when I have a callback? And sliding doesn't call the callback at all?

Open kevinrenskers opened this issue 10 years ago • 4 comments

This code will show a message that will be dismissed when you tap on it, or slide it up:

[TSMessage showNotificationWithTitle:@"Test" type:TSMessageNotificationTypeWarning];

This code however will execute the callback but not dismiss? And when I slide it up instead of tapping the callback is not triggered.

[TSMessage showNotificationInViewController:[TSMessage defaultViewController] title:@"Test" subtitle:nil image:nil type:TSMessageNotificationTypeWarning duration:TSMessageNotificationDurationEndless callback:^{
    NSLog(@"Dismissed");
} buttonTitle:nil buttonCallback:nil atPosition:TSMessageNotificationPositionTop canBeDismissedByUser:YES];

kevinrenskers avatar Dec 22 '14 15:12 kevinrenskers

I'm having the same issue. I can't dismiss nor slide it up. The callback instead gets called each time.

A quick fix for allowing dismissal upon clicking is to simply call [self fadeMeOut] yourself within the library. The problem is clearly that the handleTap function doesn't handle dismissing. An issue is that there isn't an instant variable reference to what the user set that value as, so one can't programmatically check. That should also be an easy fix.

Also, the above still won't solve the sliding up problem.

dilizarov avatar Mar 02 '15 20:03 dilizarov

"And when I slide it up instead of tapping the callback is not triggered."

I think this is by design and not a bug. When the user slides up, he clearly does not want the notification or is not interested to go into more detail concerning the specific notification; similar to Apple's notification UI. So I believe, this is intended behavior. As far as the other issue is concerned: @dilizarov provided the fix — add [self fadeMeOut] at the end of handleTap: private method in TSMessageView. I am right now even contemplating the developers commission of that statement as if it was also intended by design.

kartikthapar avatar Mar 07 '15 09:03 kartikthapar

I think everhing is OK with the logic except that when dismissingEnabled is true and self.callback != nil than there are two gesture recognizers (later GR) that can't be recognized simultaneously. So If the message can be dissmissed it adds a GR with fadeMeOut action but it is never get called because GR with handleTap: action is recognized first.

The fix would be to implement a delegate method

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
    return YES;
}

Probably it would be better to save GSs to member variables and make a check instead of just returning YES.

DanSkeel avatar Aug 28 '15 16:08 DanSkeel

No need to change library itself, just use [TSMessage dismissActiveNotification] or TSMessage dismissActiveNotificationWithCompletion:^{

as a callback: function when showing notification

synergetica11 avatar Nov 12 '15 13:11 synergetica11