Skip to content

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

Open
Kjuly wants to merge 1 commit into
KrauseFx:masterfrom
iOSLabs:master
Open

Fix bug: User tap on notif banner with callback cannot dismiss it#193
Kjuly wants to merge 1 commit into
KrauseFx:masterfrom
iOSLabs:master

Conversation

@Kjuly

@Kjuly Kjuly commented Nov 18, 2014

Copy link
Copy Markdown

It's for the issue mentioned in #179.

@KrauseFx

Copy link
Copy Markdown
Owner

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

@Kjuly

Kjuly commented Nov 18, 2014

Copy link
Copy Markdown
Author

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

lukewcn commented Dec 21, 2014

Copy link
Copy Markdown

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
Copy Markdown

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