TSMessages icon indicating copy to clipboard operation
TSMessages copied to clipboard

[TSMessage dismissActiveNotification] does not work

Open koraktor opened this issue 10 years ago • 6 comments

I'm currently facing an issue where a notification cannot be dismissed, because currentMessage.messageIsFullyDisplayed is NO here.

Situation is this: I display a message while some background job is done. After that the message is dismissed. For some reason this does not work in all cases for the reason mentioned above. It seems to be caused by the completion block not being called. I tried this in several ways: on the main thread, on a background thread, in a dispatch queue.

koraktor avatar Apr 14 '14 11:04 koraktor

That's difficult to reproduce. Could you provide an example project?

KrauseFx avatar Nov 03 '14 13:11 KrauseFx

am facing the same issue, on my case i have a navigation transition which fire a notification, then in another area of the app i fire the a new notification. only the first notification is shown...

shams-ahmed avatar Jun 05 '15 15:06 shams-ahmed

Here is an example to illustrate how dismissActiveNotification does not work:

- (void)saveToAlbum {
    [TSMessage showNotificationWithTitle:NSLocalizedString(@"Saving...", nil)
                                subtitle:self.displayName
                                    type:TSMessageNotificationTypeMessage];

    ALAssetsLibrary* library = [[ALAssetsLibrary alloc] init];
    [library writeVideoAtPathToSavedPhotosAlbum:[NSURL fileURLWithPath:self.name]
                                completionBlock:^(NSURL *assetURL, NSError *error)
     {
         [TSMessage dismissActiveNotification];
         [TSMessage showNotificationWithTitle:NSLocalizedString(@"OK", nil)
                                     subtitle:self.displayName
                                         type:TSMessageNotificationTypeSuccess];
     }];
}

The first TSMessageNotificationTypeMessage last as long as it takes no matter how soon dismissActiveNotification is called.

horaceho avatar Aug 20 '15 04:08 horaceho

@horaceho - Is there potentially an issue of the completion block not running on Main? https://developer.apple.com/library/ios/documentation/AssetsLibrary/Reference/ALAssetsLibrary_Class/index.html

johnnypayso avatar Oct 07 '15 23:10 johnnypayso

Same situation for me. I am calling dismiss before the fadeIn animation completes. Thus, messageIsFullyDisplayed == false.

if (currentMessage.messageIsFullyDisplayed) { [[TSMessage sharedMessage] fadeOutNotification:currentMessage animationFinishedBlock:completion]; }

Thus, the fadeOut never gets called if the fadeIn has not completed.

raf66 avatar Aug 16 '16 17:08 raf66

image image

jiazufei avatar Dec 29 '16 07:12 jiazufei