2015-03-30 2 views
1

У меня есть простой тест Qt приложение, которое пытается отправить уведомление пользователя на OS X:NSUserNotificationCenter defaultUserNotificationCenter возвращает нуль в приложении Qt

void Mac::notify(QString title, QString message) { 
    NSUserNotification *userNotification = [[[NSUserNotification alloc] init] autorelease]; 
    userNotification.title = title.toNSString(); 
    userNotification.informativeText = message.toNSString(); 
    NSUserNotificationCenter* center = [NSUserNotificationCenter defaultUserNotificationCenter]; 
    [center deliverNotification:userNotification]; 
} 

Проблема является NSUserNotificationCenter * центр является нулевым. Я использую Qt 5.4.1, OS X 10.10. Основная функция выглядит следующим образом:

int main(int argc, char** argv) { 
    QApplication a(argc, argv); 
    App app; 
    QQmlApplicationEngine engine; 
    engine.rootContext()->setContextProperty("app", &app); 
    engine.load(QUrl("qrc:/Main.qml")); 
    return a.exec(); 
} 

И я пытаюсь отправить уведомление на кнопку мыши

MouseArea { 
    anchors.fill: parent 
    onClicked: app.notify("Hello", "World") 
} 

Кто-нибудь есть идея, почему она не работает?

ответ

0

Наконец-то я нашел проблему. В файле Info.plist отсутствует CFBundleIdentifier. После того, как я добавил его, приложение смогло зарегистрироваться в Notification Center.

<key>CFBundleIdentifier</key> 
<string>org.notifytestosx.app</string> 
+0

commit is dead link – totaam

+0

спасибо, я удалил его – psyched