我想编写位置跟踪应用程序,如" 查找我的iPhone ",它运行在前台,后台,甚至终止(不运行).位置将定期发送到我的服务器.我在谷歌搜索并阅读了许多文档,教程评论,有关此主题的代码.然后我找到了这个教程.但在本教程中,位置被发送到前景中的".txt"文件并且后台没有终止 ...我的意思是,当应用程序被杀死时,它不会在后台重新启动以发送位置".txt"文件..所以我已经添加并更新了一些代码,以便在它没有运行时发送位置..但是,我没有这样做...我的意思是,当我在多任务中杀死(关闭)应用程序时(双击主页按钮),它是不发送到位置...
你能帮助我吗,我该如何解决这个问题?
提前致谢
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
[self log:[NSString stringWithFormat:@"Background location %.06f %.06f %@" , newLocation.coordinate.latitude, newLocation.coordinate.longitude, newLocation.timestamp]];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
id locationValue = [launchOptions objectForKey:UIApplicationLaunchOptionsLocationKey];
if (locationValue)
{
// create a new manager and start checking for sig changes
[self log:@"didFinishLaunchingWithOptions location key"];
m_locManager = [[CLLocationManager alloc] init];
[self log:@"didFinishLaunchingWithOptions created manager"];
m_locManager.delegate = self;
[self log:@"didFinishLaunchingWithOptions set delegate"];
[m_locManager startMonitoringSignificantLocationChanges];
[self log:@"didFinishLaunchingWithOptions …Run Code Online (Sandbox Code Playgroud)