标签: uilocalnotification

本地通知不在iphone中触发

我在使用动作表选择器视图.它工作正常.但是我想local notification在特定的时间开始时time picker发射,它不会发射local notification.我用过这段代码:

enter code here

      - (void)actionPickerDone {

       if (nil != self.data) {
//send data picker message[self.target performSelector:self.action     withObject:[NSNumbernumberWithInt:self.selectedIndex]];
        }
else {
    //send date picker message
    NSCalendar *calendar = [NSCalendar autoupdatingCurrentCalendar];

    // Get the current date
    NSDate *pickerDate = [self.datePicker date];
    // Break the date up into components
    NSDateComponents *dateComponents = [calendar components:( NSYearCalendarUnit | NSMonthCalendarUnit |  NSDayCalendarUnit ) 
                                                   fromDate:pickerDate];
    NSDateComponents *timeComponents = [calendar components:( NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit ) 
                                                   fromDate:pickerDate]; …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c uilocalnotification

0
推荐指数
1
解决办法
4366
查看次数

在UILocalNotification声音设置录制音频

我需要你的帮助.实际上问题是我想将录制的音频文件(保存在应用程序文档目录中)设置为用于本地通知的声音.我搜索了很多并得出结论,我们必须在本地通知中使用的声音文件必须在Application Bundle中.因此,如果在运行时在Application bundle中保存录制的音频文件的任何想法也将完成我的任务

iphone audio objective-c ios uilocalnotification

0
推荐指数
1
解决办法
1053
查看次数

在UILocalNotification中设置UserInfo时出错

我正在尝试将NSManagedObjectID附加到UILocalNotification但仍然收到错误:属性列表对格式无效:200(属性列表不能包含'CFType'类型的对象)

这是我的代码(taskID是一个NSManagedObjectID):

// Create the new notification
UILocalNotification *newNotice = [[notificationClass alloc] init];
[newNotice setFireDate:date];
[newNotice setTimeZone:[NSTimeZone defaultTimeZone]];
[newNotice setAlertBody:@"Test text"];

// Add the object ID to the userinfo
NSDictionary *myUserInfo = [NSDictionary dictionaryWithObject:taskID forKey:@"TaskID"];
newNotice.userInfo = myUserInfo;
Run Code Online (Sandbox Code Playgroud)

taskID通过此代码传递给函数(第一个参数):

addNotification([task objectID], [task taskname], [task taskexpiry]);
Run Code Online (Sandbox Code Playgroud)

task是一个NSManagedObject,并且该代码已经过测试并且工作正常了很长时间.

从我读过的一切来看,这应该有效.任何帮助将不胜感激.

贾森

objective-c userinfo uilocalnotification

0
推荐指数
1
解决办法
6439
查看次数

如何在iOS中实现"贪睡"?

我想开发一个警报应用程序并实现类似"贪睡"功能.

首先,用户使用datePicker设置时间.当用户忽略通知时,

它在5分钟后再次发出通知.

所以我使用了UILocalNotification并设置了repeatInterval = NSDayCalendarUnit

然后我可以每天收到通知,但我不知道如何实施"打盹"

仅当用户忽略第一个通知时.

alarm push-notification apple-push-notifications ios uilocalnotification

0
推荐指数
1
解决办法
1574
查看次数

获取下一个iOS本地通知的时间

获取应用的下一个本地通知时间的最佳方法是什么?

我知道可以使用以下循环来获取通知,但是这总是按时间顺序排序,所以我可以获得item [0]的时间,还是按照添加它们的顺序?怎么可以从这个时间被拉出来?我是否需要获取完整的日期并确定时间格式,还是有更好的方法?

UIApplication *app = [UIApplication sharedApplication];
NSArray *eventArray = [app scheduledLocalNotifications];
for (int i=0; i<[eventArray count]; i++)
{
    UILocalNotification* oneEvent = [eventArray objectAtIndex:i];
    //oneEvent is a local notification
    //get time of first one
}
Run Code Online (Sandbox Code Playgroud)

非常感谢!

山姆

objective-c ios uilocalnotification

0
推荐指数
1
解决办法
769
查看次数

暂停UILocalNotification

我正在制作计时器应用程序.用户设置时间,应用程序从那里倒计时.我添加了一个UILocalNotification,因此即使你不在应用程序中它也会弹出,告诉你计时器已经完成:

在我的视图控制器中:

- (void)setupLocalNotifications {
[[UIApplication sharedApplication] cancelAllLocalNotifications];

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

totalSeconds = (setHour * 60 * 60) + (setMinute * 60) + (setSecond);

NSDate *now = [NSDate date];
NSDate *dateToFire = [now dateByAddingTimeInterval:totalSeconds];

localNotification.fireDate = dateToFire;
localNotification.alertBody = @"Timer Done";
localNotification.soundName = UILocalNotificationDefaultSoundName;
localNotification.applicationIconBadgeNumber = 1; // increment

NSDictionary *infoDict = [NSDictionary dictionaryWithObjectsAndKeys:@"Object 1", @"Key 1", @"Object 2", @"Key 2", nil];
localNotification.userInfo = infoDict;

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

在我的APPDELEGATE:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window …
Run Code Online (Sandbox Code Playgroud)

objective-c ios uilocalnotification

0
推荐指数
1
解决办法
413
查看次数

从后台杀死应用程序后,UILocalnotification无法正常工作

我正在使用UIlocalnotifications,所以每当弹出一个通知,并且用户点击它时,我打开ViewController,所以每当我的应用程序处于后台时,当弹出通知,当用户点击它或应用程序图标时,我能够显示ViewController.

但是每当用户从后台杀死应用程序时,当通知发生时,如果他点击通知,我就能够显示ViewController,但是如果我点击应用程序图标,我就无法显示ViewController

以下是我的代码

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
 UILocalNotification *locationNotification = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
    if (locationNotification) {
        // Set icon badge number to zero
        application.applicationIconBadgeNumber = 0;


       AlarmViewController *alarmView = [[AlarmViewController alloc]initWithNibName: @"AlarmViewController" bundle:nil];    
    UINavigationController *navController = [[UINavigationController alloc]initWithRootViewController:alarmView];
    [self.window.rootViewController presentViewController:navController animated:YES completion:nil];

    }
}
Run Code Online (Sandbox Code Playgroud)

我试图调试这个问题,我发现的是,每当我点击应用程序图标时,它都没有得到任何本地通知.只有点击通知,我才能获得本地通知.我不知道这是一个错误,或者我是否遗漏了什么.

所以请帮帮我

问候Ranjit.

ios uilocalnotification appdelegate ios7

0
推荐指数
1
解决办法
1390
查看次数

iOS-Unity中的预定本地通知

我找不到有关发送预定本地通知的正确教程

我想出了这个,但下面的代码不起作用

void Start()

    {
        LocalNotification notif = new LocalNotification();

        notif.fireDate          = System.DateTime.Now.AddSeconds(5f);

        notif.alertBody         = "Hey";    

        NotificationServices.ScheduleLocalNotification(notif);

     }
Run Code Online (Sandbox Code Playgroud)

请在这件事上给予我帮助

unity-game-engine localnotification uilocalnotification

0
推荐指数
1
解决办法
6741
查看次数

本地通知横幅和声音在前景Objective-C中不起作用

我试图实现本地通知到我的应用程序,我实现了本地通知,但问题是.... 当我的应用程序在前台时,我没有收到通知BANNER和SOUND.但是当我的应用程序处于后台时,它运行良好.如何将通知横幅和声音带到前台..这可能吗?

这是我的一段代码......

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Handle launching from a notification
    UILocalNotification *locationNotification = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
    if (locationNotification) {
        // Set icon badge number to zero
            application.applicationIconBadgeNumber = 0;
    }
}

- (void)application:(UIApplication*)application didReceiveRemoteNotification:(NSDictionary*)userInfo
{

    if (application.applicationState == UIApplicationStateActive ) {
        NSLog(@"it entered active push");

        UILocalNotification *localNotification = [[UILocalNotification alloc] init];
        localNotification.userInfo = userInfo;
        localNotification.soundName = UILocalNotificationDefaultSoundName;
        localNotification.alertBody = userInfo[@"aps"][@"alert"][@"body"];
        localNotification.alertLaunchImage= userInfo[@"acme1"];
        localNotification.fireDate = [NSDate date];
        localNotification.applicationIconBadgeNumber = …
Run Code Online (Sandbox Code Playgroud)

objective-c ios uilocalnotification

0
推荐指数
1
解决办法
2208
查看次数

可以对UILocalNotification进行子类化并更改默认的"关闭"按钮文本和方法吗?

正在寻找一种方法来更改UILocalNotification"关闭"按钮文本/功能......

我发现从另一个对象访问/调用text/function 是不可能的,尽管子类化 UILocalNotification应该允许实现方法覆盖 ...更不用说创建一个访问器来获取/设置"关闭"按钮文本字段.

你们怎么看待这件事?Apple会怎么样?

有人试过吗?......

编辑:12/21/2011 12:01 PM

我问的问题涉及对oop的理解:延迟/早期绑定,动态方法查找,以及声明的类型与运行时类型字段和方法处理.

UILocalNotification的子类化确实有效......

UILocalNotificationExampleSubclass * example = [UILocalNotificationExampleSubclass init];

... 然而,设备创建一个对象,UILocalNotification而不是类型UILocalNotificationExampleSubclass.

我正在寻找对UILocalNotification.m文件方法的深入了解.

如果它没有自己的方法,那么什么对象(名称请)采用UILocalNotification的实例,使用它的字段,并显示我们在屏幕上看到的对象(名称)

overriding subclass objective-c uilocalnotification

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