标签: uilocalnotification

当应用程序处于工作模式时,UILocalNotification不会触发

关于为什么本地通知在这里那里没有正确启动的问题有很多问题,当应用程序处于后台状态时,还有几个问题解释为什么本地通知没有触发,我也经历了这些问题.

但令我惊讶的是,我没有找到任何与前景状态或活动状态相关的通知帖子,即在我的应用程序中我面临这个奇怪的问题,即当应用程序进入后台模式时本地通知会触发,并且当应用程序进入后台模式时它不会触发应用程序处于活动状态或前台模式,令我惊讶的是,即使在通知设置的开启日期到期后,进入后台后,通知也会立即触发.

编辑

我面临的另一个问题是警报没有触发,即我们在didReceive本地通知方法中编写的警报操作,这里是实现代码:

- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification 
{
    application.applicationIconBadgeNumber = 0;
    NSString *reminderText = [notification.userInfo objectForKey:addViewController.textField.text];
    [self.addViewController showReminder:reminderText];
}
Run Code Online (Sandbox Code Playgroud)

这是showReminder方法,它存在于另一个控制器中,即:

//Notification alert
- (void)showReminder:(NSString *)text
{
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Reminder" message:text delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];

    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(220, 10, 40, 40)];

    UIImage *image= [UIImage imageNamed:@"icon@2x.png"];
    [imageView setImage:image];

    [alertView addSubview:imageView];
    [imageView release];

    [alertView show];
    [alertView release];
}
Run Code Online (Sandbox Code Playgroud)

很抱歉,如果此问题不需要在stackoverflow中提问或发帖.

任何人请发表您的建议,任何帮助很高兴!

在此先感谢所有:)

iphone foreground uilocalnotification

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

非主要捆绑文件作为警报声

我希望我错了,但我不认为这是可能的.在"本地和推送通知编程指南"的"准备自定义警报声音"下,它说"声音文件必须位于客户端应用程序的主包中".

如果你不能写入主包,那么如何让用户生成的录音(使用AVAudioRecorder)作为警报声播放?

一方面它似乎是不可能的,但另一方面我认为有应用程序可以做到这一点(我会寻找那些).

avaudiorecorder ios uilocalnotification

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

如何判断收到了哪些本地通知?目标 - C.

我有这段代码根据收到的本地通知调用不同的NSLog语句:

- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification{
    if (notification == automaticBackupNotification)
    {
        NSLog(@"Backup notification received.");
    }
    else
    {
        NSLog(@"Did receive notification: %@, set for date:%@ .", notification.alertBody, notification.fireDate);
    }
}
Run Code Online (Sandbox Code Playgroud)

我使用此方法在另一个类中安排通知:

- (IBAction)automaticValueChanged {
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    if (automaticSwitch.isOn){
        [defaults setValue:@"1" forKey:@"automatic"];
        //schedule notification
        //Set up the local notification
        appDelegate.automaticBackupNotification = [[UILocalNotification alloc] init];
        if(appDelegate.automaticBackupNotification){
            //Repeat the notification according to frequency
            if ([backupFrequencyLabel.text isEqualToString:@"Daily"]) {
                appDelegate.automaticBackupNotification.repeatInterval = NSDayCalendarUnit;
            }
            if ([backupFrequencyLabel.text isEqualToString:@"Weekly"]) {
                appDelegate.automaticBackupNotification.repeatInterval = NSWeekCalendarUnit;
            }
            else { …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c ios uilocalnotification

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

每天下午5点重复UILocalNotification

如何在每天下午5点重复UILocalNotification?以下是我设置自定义时间的代码.但我想每天通过自定义通知用户,或者可能是静态时间.我正在使用iOS 6.

    -(void)scheduleNotification{

 NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
 [dateFormatter setDateFormat:@"h:mm a"];
NSDate *dateFromString = [[NSDate alloc] init];

dateFromString = [dateFormatter dateFromString:timeStr];

UILocalNotification *localNotif = [[UILocalNotification alloc] init];

if (localNotif == nil)
    return;


localNotif.fireDate = dateFromString;

localNotif.repeatInterval = kCFCalendarUnitDay;
localNotif.timeZone = [NSTimeZone defaultTimeZone];

// Notification details
localNotif.alertBody = @"Reminder is set";
// Set the action button
localNotif.alertAction = @"Ok";

localNotif.soundName = UILocalNotificationDefaultSoundName;
localNotif.applicationIconBadgeNumber = 1;

// Specify custom data for the notification
NSDictionary *infoDict = [NSDictionary dictionaryWithObjectsAndKeys:@"Local Push received while …
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch objective-c ios uilocalnotification

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

适用于Android的Phonegap Local Notification Plugin

我正在Android上使用Phonegap [Cordova 2.2]开发"Reminders"应用程序.

用户输入提醒的具体日期,我应该按时通知他.

我使用这个插件只是在状态栏中显示通知并且它们正常工作.

但我希望通知在特定时间显示.有办法吗?

我发现这个插件本应该做我想要的但是它不起作用,它显示错误:

import com.phonegap.api.Plugin;
import com.phonegap.api.PluginResult;
Run Code Online (Sandbox Code Playgroud)

导入com.phonegap.api.Plugin无法解析

那么,我该如何解决这个错误呢?我知道这可能很容易,但我之前从未制作原生的Android应用程序,所以我有点困惑.

谢谢

android statusbar uilocalnotification cordova

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

有关iOS上的本地通知的问题

我现在在应用程序中使用本地通知,但我发现一些奇怪的东西.

我设置并安排了这样的通知.

UILocalNotification *localNotif = [[UILocalNotification alloc] init];
if (localNotif == nil) {
    return;
}
NSDate *now = [[NSDate alloc] init];
now = [now dateByAddingTimeInterval:dayToFinish * 24 * 60 * 60];
NSDateComponents *components = [[NSCalendar currentCalendar] components:NSHourCalendarUnit fromDate:now];

components = [[NSCalendar currentCalendar] components:NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit fromDate:now];
int month = [components month];
int day = [components day];
int year = [components year];

NSCalendar *calendar = [NSCalendar autoupdatingCurrentCalendar];
NSDateComponents *dateComps = [[NSDateComponents alloc] init];
[dateComps setYear:year];
[dateComps setMonth:month];
[dateComps setDay:day]; …
Run Code Online (Sandbox Code Playgroud)

objective-c ios uilocalnotification

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

UILocalNotification设置repeatCalendar

我是新来的NSCalander,NSdatesNSDateComponents

基本上我有一个本地通知,我想根据用户的选择重复开火日期,让我们说只在周日和周一.

我们应该使用repeatCalendar属性UILocalNotification但我无法达到如何设置它.

那么任何人都能用简单的代码行帮助我吗?

谢谢

nsdate nscalendar ios uilocalnotification nsdatecomponent

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

iOS8 - UILocalNotification,稍后从代码中检查权限

我正在使用Swift for iOS8编写我的应用程序.

我想使用UILocalNotification来通知用户一些事情.为此,我已在应用程序启动时请求权限:

application.registerUserNotificationSettings(UIUserNotificationSettings(forTypes: UIUserNotificationType.Sound | UIUserNotificationType.Alert | UIUserNotificationType.Badge, categories: nil))
Run Code Online (Sandbox Code Playgroud)

确认框显示要求许可.如果用户允许,则没有问题.

如果用户未授予权限,如何检查是否已从代码启用本地通知(以编程方式)?

uilocalnotification swift ios8

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

每周特定日期的本地通知

我需要在一周的每个工作日(不是星期六和星期日)发布特定时间(例如18.00)的本地通知,但我找不到示例或教程.我想用swift2.1.我该如何创建此通知?我的问题是正确定义通知的被激活

notifications ios uilocalnotification ios9 swift2

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

UILocalNotification会在iOS 10上崩溃吗?

这是当前的UILocalNotification类,这是苹果刚刚在wwdc 16中宣布的iOS 10 UserNotification.

使用的旧应用程序UILocalNotification是否会在iOS 10上崩溃?

objective-c ios uilocalnotification swift ios10

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