标签: notifications

取消UILocalNotification

我的UILocalNotification有问题.

我正在使用我的方法安排通知.

- (void) sendNewNoteLocalReminder:(NSDate *)date  alrt:(NSString *)title
{
    // some code ...
    UILocalNotification *localNotif = [[UILocalNotification alloc] init]; 

    if (localNotif == nil)  
        return;

    localNotif.fireDate = itemDate; 
    localNotif.timeZone = [NSTimeZone defaultTimeZone];
    localNotif.alertAction = NSLocalizedString(@"View Details", nil); 
    localNotif.alertBody = title;
    localNotif.soundName = UILocalNotificationDefaultSoundName; 
    localNotif.applicationIconBadgeNumber = 0;

    NSDictionary *infoDict = [NSDictionary dictionaryWithObject:stringID forKey:@"id"]; 
    localNotif.userInfo = infoDict; 

    [[UIApplication sharedApplication] scheduleLocalNotification:localNotif]; 
    [localNotif release];
}
Run Code Online (Sandbox Code Playgroud)

它工作正常,我正确收到通知.问题是我应该取消通知.我正在使用这种方法.

- (void) deleteNewNoteLocalReminder:(NSString*) reminderID noteIDe:(NSInteger)noteIDE
{
    [[UIApplication sharedApplication] cancelLocalNotification:(UILocalNotification *)notification ????  
}
Run Code Online (Sandbox Code Playgroud)

我不知道该怎么做,但我的问题是:

我如何知道应删除哪个UILocalNotification对象?
有没有办法列出所有通知?

我唯一拥有的是我应删除的提醒ID.
我正在考虑将UILocalNotification对象保存在我的"Note"对象中并以此方式获取,当我保存到我的SQLite数据库时序列化对象等等......是否有更聪明的方法?

iphone notifications cocoa-touch ios4

48
推荐指数
5
解决办法
4万
查看次数

如何处理有关核心数据,共享偏好和通知的Mac OS X Helper/Main应用程序架构?

我对一个正在研究的项目(Mac OS X应用程序)有一些架构上的怀疑.它基本上由两个元素组成:一个在后台运行的守护进程收集一些数据,一个查看器用于表示收集的数据.

守护程序应在状态栏中显示(无停靠图标),并包含可通过状态栏访问的小菜单.它将数据保存在核心数据存储中.其中一个菜单项是打开查看器链接.打开此查看器时,正常的 GUI应用程序应该开始包括停靠图标和菜单栏.打开应用程序本身时也会打开查看器(通过双击图标).

经过一些实验,我发现实现这个功能的最好方法是创建两个应用程序,代表查看器的主应用程序和代表守护进程的辅助工具.我这样做的原因之一是不能LSUIElement立即在值之间切换以强制守护进程/查看器状态.

现在我对这个架构有一些疑问:

  • 守护程序和查看器应用程序都使用相同的核心数据存储来保存和检索数据.拥有多线程应用程序时,我知道NSManagedObjectContext需要多个对象才能正确同步数据.如何让多个应用程序同时使用相同的核心数据存储?这是否可能没有冲突,锁定等风险?我如何保证一致性?

  • 守护程序应始终在查看器启动时启动.我通过简单地遍历所有打开的进程并检查是否列出了守护进程的bundle标识符来实现这一点.如果没有,守护进程使用NSWorkspace's' 开始launchApplication.这很好用.现在,当用户退出守护程序时,查看器也应该停止.查看器通知守护程序停止的最佳方法是什么?如果守护程序消失,我可以定期检查活动进程并退出查看器但听起来有点奇怪.我希望选择某种通知,当观众即将关闭时,我会发送这些通知.但由于应在应用程序之间发送和捕获此通知,因此我不知道哪种简单通知服务可用.有什么想法吗?

  • 该应用程序是沙盒,因为它将在Mac App Store上分发.使用NSWorkspace's 启动应用程序launchApplication会导致目标应用程序在与我认为根本不是问题的源相同的沙盒环境中运行,因为在同一个沙箱中运行这两个应用程序感觉更好,可能是.但想象一下这个场景:守护进程在登录时自动启动(使用SMLoginItemSetEnabled),用户双击Viewer.app.由于守护程序已在运行(再次通过循环执行活动进程来检查),它将无法启动.现在我们有守护进程和查看器在不同的沙箱中运行吗?这会导致偏好,核心数据存储等问题吗?

  • 我想NSUserDefaults用于基本配置,我可以以某种方式在守护进程和查看器之间交换这些数据吗?同样,两个应用程序将具有不同的包标识符.

在此先感谢您的帮助,谢谢!

macos notifications daemon core-data helpers

48
推荐指数
1
解决办法
968
查看次数

缺少推送通知权利

在提交二进制版本后,我收到了Apple的警告邮件.

    Missing Push Notification Entitlement - Your app appears to include API used to register with the Apple Push Notification service, but the app signature's entitlements do not include the "aps-environment" entitlement.
If your app uses the Apple Push Notification service, make sure your App ID is enabled for Push Notification in the Provisioning Portal, and resubmit after signing your app with a Distribution provisioning profile that includes the "aps-environment" entitlement. 
See "Provisioning and Development" in the Local and Push …
Run Code Online (Sandbox Code Playgroud)

notifications apple-push-notifications ios

47
推荐指数
3
解决办法
2万
查看次数

Python中的跨平台桌面通知程序

我在Python中寻找类似Growl的,类似于气球提示的通知库.想象一下编写如下代码:

>>> import desktopnotifier as dn
>>> dn.notify('Title', 'Long description goes here')
Run Code Online (Sandbox Code Playgroud)

..并且会通过Mac,Windows和Linux上的相应工具提示进行通知.这样的图书馆存在吗?如果没有,我将如何自己写一个?

  • Mac是否附带默认通知程序?是咆哮我应该单独安装的东西吗?
  • 在Windows上,我认为这可能需要pywin32
  • 在Linux上,假设GNOME,是否有GNOME API(使用gnome-python)来做到这一点?
  • 我可以在所有平台上发出"粘性"通知(即,不要淡出)吗?

更新:我的偏好是依赖于像PyQT4和wxPython这样的巨大GUI框架来完成这样的简单任务.

python desktop notifications cross-platform growl

46
推荐指数
4
解决办法
2万
查看次数

Toastr:如何防止在鼠标悬停时使用粘性吐司淡出?

我一直在玩toastr并且已经成功地将超时设置为0,因此吐司仍然是粘性的,但是当我将鼠标移出吐司时吐司消失了.我想要覆盖它,所以如果用户点击它,烤面包就会消失 - 非常适合有大量文字的祝酒词.如何才能做到这一点?

notifications messages mouseover sticky toastr

46
推荐指数
2
解决办法
2万
查看次数

45
推荐指数
3
解决办法
8万
查看次数

您如何在RoR中创建SO或Facebook等通知系统?

我认为通知将是它自己的资源,并且has_many, through与用户模型有关系,并且连接表表示关联.

具有许多通知的用户是显而易见的,然后通知将具有许多用户,因为将存在与许多用户相关联的多个标准化通知(评论通知,后续通知等).

除此设置外,我不确定如何根据应用程序中的某些事件触发通知创建.我也不确定如何设置路由 - 它是自己独立的资源还是嵌套在用户资源中?如果有人可以对此进行扩展,我会发现它非常有用.

最后,ajax轮询可能会改善这样的功能.

可能有一些我缺少的东西,所以请填写它,以便它是一个很好的一般资源.

ruby notifications ruby-on-rails push-notification ruby-on-rails-3

44
推荐指数
2
解决办法
1万
查看次数

可以从工作线程调用NoticationManager.notify()吗?

我的问题更多的是关于什么是好的做法而不是可能的做法:

  • NoticationManager.notify()从工作线程调用是一件好事吗?
  • 系统是否在UI线程中执行它?

我总是试着记住,关于UI的东西应该在UI线程中执行,其余的在工作线程中执行,如Android doc关于进程和线程的建议:

此外,Andoid UI工具包不是线程安全的.因此,您不能从工作线程操纵UI - 您必须从UI线程对您的用户界面进行所有操作.因此,Android的单线程模型只有两个规则:

  • 不要阻止UI线程
  • 不要从UI线程外部访问Android UI工具包

然而,我对Android doc本身给出的一个例子感到惊讶(关于显示Notifications的进展),其中正在进行的通知进度直接从工作线程更新:

mNotifyManager =
        (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mBuilder = new NotificationCompat.Builder(this);
mBuilder.setContentTitle("Picture Download")
    .setContentText("Download in progress")
    .setSmallIcon(R.drawable.ic_notification);
// Start a lengthy operation in a background thread
new Thread(
    new Runnable() {
        @Override
        public void run() {
            int incr;
            // Do the "lengthy" operation 20 times
            for (incr = 0; incr <= 100; incr+=5) {
                    // Sets the progress indicator to a max value, the …
Run Code Online (Sandbox Code Playgroud)

notifications multithreading android android-notifications

43
推荐指数
1
解决办法
8040
查看次数

通知多行

如何制作长通知多行.我使用下面的代码片段,但它无法正常工作:

NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
  .setContentTitle(title)
  .setSmallIcon(R.drawable.icon)
  .setStyle(new NotificationCompat.BigTextStyle().bigText(message))
  .setContentText(message)
  .setContentIntent(pIntent);

return mBuilder.build();
Run Code Online (Sandbox Code Playgroud)

notifications android

43
推荐指数
3
解决办法
4万
查看次数

使用php和mysql的通知系统

我想为我们学校实施一个通知系统,它是一个不为公众开放的php/mysql webapp,因此它不会收到太多流量."每日500-1000名访客".

1.我最初的方法是使用MYSQL触发器:

我使用Mysql AFTER INSERT trigger将记录添加到名为的表中notifications.就像是.

'CREATE TRIGGER `notify_new_homwork` AFTER INSERT ON `homeworks`
 FOR EACH ROW INSERT INTO `notifications` 
    ( `from_id`, `note`, `class_id`) 
 VALUES 
    (new.user_id, 
        concat('A New homework Titled: "',left(new.title,'50'),
        '".. was added' )
    ,new.subject_id , 11);'
Run Code Online (Sandbox Code Playgroud)

这种黑魔法工作得非常好,但我无法跟踪这个通知是否是新的"显示用户新通知的数量".所以我添加了一个名为notification的页面.

通过类似的方式检索通知

SELECT n.* from notifications n 
JOIN user_class on user_class.class_id = n.class_id where user_class.user_id = X;
Run Code Online (Sandbox Code Playgroud)

注意:表user_class将用户链接到类"user_id,class_id,subject_id"-subject为null,除非用户是教师'

现在我的下一个挑战是.

  1. 如何跟踪每个用户的新旧通知?
  2. 如何将与用户类似的通知聚合到一行?

例如,如果2个用户对某些内容发表了评论,那么就不要插入新行,只需使用"userx和其他1个在hw上注释"的内容更新旧行.

非常感谢

编辑

根据下面的答案,要在行上设置读/未读标志,我需要为每个学生设置一行而不仅仅是整个类的一行..这意味着将触发器编辑为类似

insert into notifications (from_id,note,student_id,isread)
select new.user_id,new.note,user_id,'0' from user_class where user_class.class_id = new.class_id group by …
Run Code Online (Sandbox Code Playgroud)

php mysql notifications triggers

43
推荐指数
1
解决办法
5万
查看次数