Presenting a local notification immediately while running in the background
来源:互联网 发布:python keras实例 编辑:程序博客网 时间:2024/06/05 08:05
- (void)applicationDidEnterBackground:(UIApplication *)application { NSLog(@"Application entered background state."); // bgTask is a property of the class NSAssert(self.bgTask == UIInvalidBackgroundTask, nil); bgTask = [application beginBackgroundTaskWithExpirationHandler: ^{ dispatch_async(dispatch_get_main_queue(), ^{ [application endBackgroundTask:self.bgTask]; self.bgTask = UIInvalidBackgroundTask; });}]; dispatch_async(dispatch_get_main_queue(), ^{ while ([application backgroundTimeRemaining] > 1.0) {init];friend];nil);NSString *friend = [self checkForIncomingChat];if (friend) { UILocalNotification *localNotif = [[UILocalNotification alloc] if (localNotif) { localNotif.alertBody = [NSString stringWithFormat: NSLocalizedString(@"%@ has a message for you.", nil), localNotif.alertAction = NSLocalizedString(@"Read Message", localNotif.soundName = @"alarmsound.caf"; localNotif.applicationIconBadgeNumber = 1; [application presentLocalNotificationNow:localNotif]; [localNotif release]; friend = nil; break;} } } [application endBackgroundTask:self.bgTask]; self.bgTask = UIInvalidBackgroundTask;});}
0 0
- Presenting a local notification immediately while running in the background
- Running in a Background Service 之Sending Work Requests to the Background Service
- Running in a Background Service 之Creating a Background Service
- Loading Data in the Background 之Running a Query with a CursorLoader
- 高级bash编程一书Example 3-3. Running a loop in the background的问题
- Completing a Long-Running Task in the Background(在后台完成长时间运行的任务)
- background and notification of local
- Running GPS positioning in a background thread on Android
- Running in a Background Service 之Reporting Work Status
- Running a Service in the Foreground
- How to write a console application running in background (hidden window)?
- Loading Resources In The Background With A Loading Screen
- 【Multitasking】Executing a Finite-Length Task in the Background
- Working in the Background
- iOS合理利用Local Push和Long-running background task
- SQL Programming(5):Presenting Data in a Table View
- getting a job while studying in the United States
- Creating, configuring, and scheduling a local notification
- NYOJ-小数阶乘
- 回溯法(scheme) -- N皇后问题
- JTextField正则表达式
- 哄媳妇
- 设置JPanel的背景
- Presenting a local notification immediately while running in the background
- Yale开放课程博弈论2
- Unity3d面试总结
- 分支限界法(scheme) -- 最短路径问题
- iOS代码截图
- Queueing in the Linux Network Stack
- 民营企业的十三种死法
- Codeforces Round #264 (Div. 2)
- Linux常用命令大全