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

User interactions to dismiss notification not working #206

Open
r-shayestehpour opened this issue Aug 9, 2016 · 3 comments
Open

User interactions to dismiss notification not working #206

r-shayestehpour opened this issue Aug 9, 2016 · 3 comments

Comments

@r-shayestehpour
Copy link

I have this swift code:


static func showToast(message: String, type: NetworkToastType, isLong: Bool = false , completion: (() -> Void)! = nil) {

        let v = CRToastInteractionResponder(interactionType: .All, automaticallyDismiss: true) { type in
            CRToastManager.dismissNotification(true)
            print("HELLO!")
        }

        var options : [NSObject: AnyObject] = [
            kCRToastTextKey: message,
            kCRToastFontKey: UIFont(name: "myFont", size: 15)!,
            kCRToastTextAlignmentKey: NSTextAlignment.Center.rawValue,
            kCRToastAnimationInDirectionKey: CRToastAnimationDirection.Top.rawValue,
            kCRToastAnimationOutDirectionKey: CRToastAnimationDirection.Top.rawValue,
            kCRToastInteractionRespondersKey: v
        ]

        options[kCRToastNotificationTypeKey] = isLong ? CRToastType.NavigationBar.rawValue : CRToastType.StatusBar.rawValue

        options[kCRToastTimeIntervalKey] = isLong ? 4.0 : 1.5

        CRToastManager.showNotificationWithOptions(options, completionBlock: completion)
    }

I think the interaction responder should dismiss the notification on any user interaction but not only it does not do that, but also the closure is not called("HELLO is never printed on interactions"). What am I doing wrong?

@LucasVanDongen
Copy link

LucasVanDongen commented Dec 3, 2016

Same problem here.

Turned out it expects an array of responders:

kCRToastInteractionRespondersKey: [interactionResponder!] as NSArray

I think I would prefer an object with settings over a dictionary, in that case the compiler would've yelled at me.

@SomersJan
Copy link

@LucasVanDongen

Does this workaround still work, since it doesn't for me (I use obj-c)

@SomersJan
Copy link

I can confirm that the solution LucasVanDongen gave works !

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

No branches or pull requests

3 participants