Tag: uilocalnotification

从本地通知启动封闭的iOS应用程序

当我的iOS应用程序在后台运行,它响应很好 – (void)application:(UIApplication *)application didReceiveLocalNotification: (UILocalNotification *)notification 但是当应用程序closures时,它会崩溃,并提供一个SIGKILL错误。 如果在收到通知时closures应用程序,我该如何运行一个方法?

本地通知每一天的特定日子

我需要创build一个特定时间的本地通知(例如在18.00)解雇了每星期的工作日(不是星期六和星期天),但我找不到示例或教程。 我想用swift2.1。 我怎样才能创build这个通知? 我的问题是正确定义通知

操作button不会在本地通知中显示ios 9.2 swift 2

我正在循环中创build通知,相关的代码是: func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { appDelegate = self serNotificationType = UIUserNotificationType.Alert.union(UIUserNotificationType.Sound).union(UIUserNotificationType.Badge) let completeAction = UIMutableUserNotificationAction() completeAction.identifier = "COMPLETE" // the unique identifier for this action completeAction.title = "Clear" // title for the action button completeAction.activationMode = .Background // UIUserNotificationActivationMode.Background – don't bring app to foreground completeAction.authenticationRequired = false // […]

在UILocalNotification声音比AVAudioPlayer在最大音量

为了这个问题的目的,想象我的应用程序每10秒播放一个audio剪辑。 此audio使用AVAudioPlayer播放/与设备上的iPod音乐播放器(使用低频)混合。 当应用程序被发送到后台,我安排UILocalNotification对象与audio文件引用(和没有文字),所以声音继续播放以10秒为间隔。 令我困扰的是,在iOS 6上作为通知的一部分播放的audio剪辑的音量似乎是我在应用程序中播放audio时的两倍(我将音量设置为1.0f,文档说是最大)。 所以,每隔10秒钟,应用程序就会播放声音,当您发送到背景时,与应用程序中的内容相比,现在声音非常响亮。 相关片段…应用程序启动,这里是我如何设置AVAudioSession,以启用ducking: [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil]; UInt32 doChangeDefaultRoute = 1; AudioSessionSetProperty (kAudioSessionProperty_OverrideCategoryDefaultToSpeaker, sizeof (doChangeDefaultRoute), &doChangeDefaultRoute); OSStatus propertySetError = 0; UInt32 allowMixing = true; propertySetError = AudioSessionSetProperty (kAudioSessionProperty_OverrideCategoryMixWithOthers,sizeof (allowMixing),&allowMixing); …我如何创build我的球员: – (AVAudioPlayer *)playerWithCAFFileNamed:(NSString *)fname { NSURL *u = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:fname ofType:@"caf"]]; NSData *d = [NSData dataWithContentsOfURL:u]; AVAudioPlayer *p = […]

iPhone的UILocalNotification加载特定的视图

我有我的本地通知工作,但是当我点击视图回到应用程序,在应用程序委托我试图加载一个特定的视图,但它不会采取。 这可能吗? 它总是回到最后的观点。

本地通知在不同的时间重复

我有一个应用程序,产生祈祷时间(一天5次),我想创build通知5祈祷,但问题是每天的时代变化,根据一些计算。 编辑: 计算是基于GPS定位完成的,所以当用户更换到另一个城市时,相应地更新时间。 我inputdate,时区,GPS坐标到一个方法,我得到的礼拜时间值(HH:毫米)格式为给定的一天/位置。 现在我需要设置Notfications。 我不确定在哪里设置它们。 这里是代码 #import "PrayerTimeViewController.h" #import "PrayTime.h" @implementation PrayerTimeViewController – (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization UITabBarItem *tbi = [self tabBarItem]; [tbi setTitle:NSLocalizedString(@"PrayerTimes", nil)]; UIImage *i = [UIImage imageNamed:@"11-clock"]; [tbi setImage:i]; [i release]; } return self; } – (void)didReceiveMemoryWarning { // […]

本地通知声音没有播放?

我遇到了本地通知的问题,他们没有播放声音。 我用默认的和自定义的那个进行了testing,显然是我想玩的,但没有任何东西! 我看了很多人面对这个问题,但他们的解决scheme没有为我工作。 UILocalNotification *local – (IBAction)Dateaction:(id)sender { local = [[UILocalNotification alloc]init]; local.timeZone = [NSTimeZone defaultTimeZone]; local.alertBody = [NSString stringWithFormat:@"%@ Recuerda que tienes que: %@", [[NSUserDefaults standardUserDefaults] objectForKey:@"user"], [[NSUserDefaults standardUserDefaults] objectForKey:@"selected"]]; local.fireDate = [self.DatePicker date]; /* if ([[self.userdefaults objectForKey:@"sound"]isEqualToString:@"sound1"]) { local.soundName = @"sound1.caf"; }else if([[self.userdefaults objectForKey:@"sound"]isEqualToString:@"sound2"]){ local.soundName = @"sound2.caf"; }else if([[self.userdefaults objectForKey:@"sound"]isEqualToString:@"sound1"]){ local.soundName = @"sound3.caf"; […]

每天午夜设置本地通知

我试图创build一个简单的通知,每天午夜出现。 这是我使用的代码: func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Override point for customization after application launch. application.registerUserNotificationSettings(UIUserNotificationSettings(forTypes: UIUserNotificationType.Sound | UIUserNotificationType.Alert | UIUserNotificationType.Badge, categories: nil)) var thisDate = NSDateComponents() thisDate.hour = 0 thisDate.minute = 0 thisDate.second = 0 var calender = NSCalendar() var localNotification:UILocalNotification = UILocalNotification() localNotification.timeZone = NSTimeZone.localTimeZone() localNotification.fireDate = calender.dateFromComponents(thisDate) […]

处理本地通知时,用户按下图标,而不是警报

以下是我想处理苹果文档引用的情况。 作为提示通知的结果,用户点击警报的动作button或点击(或点击)应用程序图标。 如果点击操作button(在运行iOS的设备上),系统启动应用程序,应用程序调用其代理的应用程序:didFinishLaunchingWithOptions:方法(如果已实施); 它传入通知负载(用于远程通知)或本地通知对象(用于本地通知)。 如果在运行iOS的设备上点击应用程序图标,应用程序将调用相同的方法,但不提供有关通知的信息。 如果在运行OS X的计算机上单击应用程序图标,应用程序将调用代理的applicationDidFinishLaunching:方法,在该方法中代理可以获取远程通知有效内容。 如果没有关于通知的信息,我该如何处理这种情况?

下次启动应用程序时,我可以解除本地通知吗?

我知道当用户在通知中心点击此通知时,我可以取消通知。 但是我可以在其他地方取消通知,我无法从系统获得相关的本地通知。 我可以序列化本地通知,并在下次运行应用程序时取消它? 对不起,让你误会! 我想在通知中心解散已发布的通知,但不是预定的通知。 所以我想问的是如何保存本地通知对象,然后我可以使用它在下次启动应用程序时自行解除。 也许这个工作不能用现在的SDK来完成。