TSMessages
TSMessages copied to clipboard
Fix bug: User tap on notif banner with callback cannot dismiss it
It's for the issue mentioned in #179.
Could you please briefly explain what you've changed and why?
When i set callback
for the message like below:
[TSMessage showNotificationInViewController:yourViewController
title:@"title"
subtitle:@"subtitle"
image:nil
type:TSMessageNotificationTypeSuccess
duration:TSMessageNotificationDurationAutomatic
callback:^{
// here do whatever u want after user tapped the banner
}
buttonTitle:nil
buttonCallback:nil
atPosition:TSMessageNotificationPositionTop
canBeDismissedByUser:YES];
the tap action that generated by canBeDismissedByUser:YES
will be overrode by callback's (which means, it'll invoke -handleTap
instead of -fadeMeOut
when user tapped on message), that'll leads the notification banner cannot dismiss. Because -handleTap
has not implement fade out action.
if (dismissingEnabled) {
UISwipeGestureRecognizer *gestureRec = [[UISwipeGestureRecognizer alloc] initWithTarget:self
action:@selector(fadeMeOut)];
[gestureRec setDirection:(self.messagePosition == TSMessageNotificationPositionTop ?
UISwipeGestureRecognizerDirectionUp :
UISwipeGestureRecognizerDirectionDown)];
[self addGestureRecognizer:gestureRec];
UITapGestureRecognizer *tapRec = [[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(fadeMeOut)];
[self addGestureRecognizer:tapRec];
}
if (self.callback) {
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
tapGesture.delegate = self;
[self addGestureRecognizer:tapGesture];
}
Here, just invoke the callback block, no action to fade out the banner.
- (void)handleTap:(UITapGestureRecognizer *)tapGesture
{
if (tapGesture.state == UIGestureRecognizerStateRecognized)
{
if (self.callback)
{
self.callback();
}
}
}
YES, User tap on notif banner with callback cannot dismiss it, i encounter this issue too, please update pods, thanks very much~
Same issue for me, sorry for the duplicate (#201)