MacGapProject / MacGap1

Desktop WebKit wrapper for HTML/CSS/JS applications.
Other
3.55k stars 209 forks source link

10.8 notifications #57

Open Macmee opened 12 years ago

Macmee commented 12 years ago

Is anybody having problems with making desktop notifications show up in 10.8?

Growl works but not natives.

KevinGroenendaal commented 11 years ago

Same here. Any chance the user has to set permission in order to have it work?

wspringer commented 11 years ago

I also have the same problem. It seems the thread dies after trying to send the notifications.

christopherjones commented 11 years ago

My problem is that the notification shows up in notification center, but it never pops up. It just shows in the drawer.

gobijan commented 10 years ago

no notifications on 10.9.2 :/

jeff-h commented 10 years ago

I'm hoping to get https://github.com/maccman/macgap/pull/87 included soon, at which time I'll test it all to be sure it works.

Notifications do work for me now (on 10.9.2), although honestly they seem sometimes to only show up in the notification centre but not pop up (just like @christopherjones said above). I have ignored this problem to date, thinking perhaps that it happens only when I'm running the debug version of my app from inside Xcode as opposed to a packaged up version of my app. Not sure how true that is. I'll have more of a dig into that theory sometime over the next week or so.

zerosix commented 10 years ago

if two instances of the built app are open at the same time, notifications pop up and work as expected on the second instance for some reason.

jeff-h commented 10 years ago

https://github.com/maccman/macgap/pull/87 is now rolled in. However, this issue is still a problem for me.

@zerosix I tried what you suggested by duplicating the compiled MacGap app and opening both copies but didn't get the results you describe.

I did find that with Xcode quit, the MacGap app did create notifications properly except that they only ever appeared in the sidebar notifications area, and never popped up on my screen (similar to what @christopherjones said above).

JLarky commented 10 years ago

Yay for merged pull request :) As for issue: native notifications popup shown only if application is in background. This is default and documented behavior. This is why it works this way if two instances of the built app are open at the same time, notifications pop up and work as expected on the second instance for some reason.

This can be changed by this in Notice.m

- (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentNotification:(NSUserNotification *)notification
{
    return YES;
}

google shouldPresentNotification for more

jeff-h commented 10 years ago

@JLarky Woohoo! Thanks so much for clearing this up. Your explanation makes absolute sense — I feel silly for not having realised this as the reason.

I've added a note to the documentation at https://github.com/maccman/macgap/wiki/Notice to this effect.

Do you think we could add the shouldPresentNotification as an option settable from JavaScript?

JLarky commented 10 years ago

@jeff-h I was going to add this option, but I didn't have time (I haven't have any experience with Obective C other than in macgap). But If someone else want to implement it, I think it can be done. I think main problem here is to have good API. Proper implementation would require shouldPresentNotification flag for each notification, but then you have to store this flag somehow (and I don't have enough experience to know how), and simplest implementation can just have some kind of setAllNotificationsPresend that will be stored in some kind of global variable for whole app.

This is to say I'm glad I was helpful so far, but I hope you guys would know how to do it best for the rest of this feature :)