Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug: User tap on notif banner with callback cannot dismiss it #193

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Kjuly
Copy link

@Kjuly Kjuly commented Nov 18, 2014

It's for the issue mentioned in #179.

@KrauseFx
Copy link
Owner

Could you please briefly explain what you've changed and why?

@Kjuly
Copy link
Author

Kjuly commented Nov 18, 2014

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();
        }
    }
}

@lukewcn
Copy link

lukewcn commented Dec 21, 2014

YES, User tap on notif banner with callback cannot dismiss it, i encounter this issue too, please update pods, thanks very much~

@kevinrenskers
Copy link

Same issue for me, sorry for the duplicate (#201)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants