Tag: 背景服务

在后台模式下调用Web服务 – iOS

我需要每分钟调用一次Web服务,并在应用程序处于后台状态时parsing数据。 由于APP使用位置服务,我已启用后台模式更新位置。 我试图通过使用定时器后台任务来调用位置更新,但它不工作。 – (void)applicationDidEnterBackground:(UIApplication *)application { self.bgTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{ NSLog(@"ending background task"); [[UIApplication sharedApplication] endBackgroundTask:self.bgTask]; self.bgTask = UIBackgroundTaskInvalid; }]; self.timer = [NSTimer scheduledTimerWithTimeInterval:60 target:self.locationManager selector:@selector(startUpdatingLocation) userInfo:nil repeats:YES]; } 有没有什么办法可以用更less的电池消耗来实现这一点。 我提到这个链接,我没有得到哪个解决scheme在这里更好。

在iOS中有没有相当于Android的服务?

我想检查我的应用程序中的数据库每12小时的行date列有相应的date。 这是通过在android中编写服务来完成的。 但是在iOS中有没有相当的服务,以便我的要求可以完成?

ios nstimer在后台运行检查报警时间等于当前时间并播放audio

我GOOGLE了几个小时,但无法find任何信息,如果有任何方式来保持运行NSTimer活动时,应用程序在后台运行? 请帮助我,当应用程序是背景,然后一个function运行,每秒检查报警时间等于当前时间,然后播放audio,并打开closures报警页面如果有人知道闹钟应用程序开源,并在后台运行,请与我分享在这里,我尝试这个,但是这不起作用 – (void)applicationDidEnterBackground:(UIApplication *)application { inBackground=YES; UIApplication* app = [UIApplication sharedApplication]; bgTask = [app beginBackgroundTaskWithExpirationHandler:^{ [app endBackgroundTask:bgTask]; bgTask = UIBackgroundTaskInvalid; }]; // Start the long-running task and return immediately. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ while (inBackground == YES) { [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(checkAlert) userInfo:nil repeats:YES]; } [app endBackgroundTask:bgTask]; bgTask = UIBackgroundTaskInvalid; }); } -(void)checkAlert { NSLog(@"Chalaaaaaa"); […]

iOS:使应用程序像服务一样运行

在iOS中,我将如何指示操作系统保持我的应用程序运行,即使它不在前台? Skype的 Viber的 Empatica Zenly 还有更多的应用程序这样做。