我想在应用程序终止或背景时每10分钟从后台发送位置。 请给代码以及如何使用它.. 这是可能的,如果是,那么建议我 感谢如何在应用程序终止时发送背景位置
0
A
回答
0
确保你添加以下到你的头:
@interface ViewController : UIViewController<CLLocationManagerDelegate>
包括框架:
在导航器中点击您的项目。
点击下的“库链接二进制”
添加Corelocation到项目的加号按钮。
导入头文件:
#import <CoreLocation/CoreLocation.h>
声明CLLocationManager:
CLLocationManager *locationManager;
ViewController.m
- (void)viewDidLoad {
[super viewDidLoad];
NSLog(@"today monday");
myTimer = [NSTimer scheduledTimerWithTimeInterval: 60.0 target: self
selector: @selector(first:) userInfo: nil repeats: YES];
}
-(void)first:(id)sender
{
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager startUpdatingLocation];
NSLog(@"called");
[self.view setBackgroundColor:[UIColor greenColor]];
CLLocationCoordinate2D coordinate;
NSString * currentLat = [NSString stringWithFormat:@"%f",coordinate.latitude];
NSString * currentLong = [NSString stringWithFormat:@"%f",coordinate.longitude];
NSLog(@"latitude %@",currentLat);
NSLog(@"longitude %@",currentLong);
}
的NSTimer可以称为以往第一方法1英里n
试试这个,希望对你有所帮助
+0
这段代码将运行时,应用程序在背景或前景..我想在应用程序被终止或终止状态时发送位置 – 2014-11-03 06:54:56
+0
@ShashankPrinceMishra currentLat和currentLong值传递给服务器 – 2014-11-03 07:03:22
相关问题
- 1. 如何重置应用程序,当发送到背景
- 2. objc_msg发送应用程序将终止
- 3. 下载终止时,应用程序进入背景
- 4. 如何发送终止信号来停止Rails应用程序?
- 5. iOS应用程序背景位置(推送通知)
- 6. 防止achartengine和textview重置后,并将应用程序发送到背景
- 7. 当应用程序终止时iOS 10更新位置
- 8. 如何禁止在写入文件时终止应用程序
- 9. 如何在用户看不到应用程序时停止背景音乐
- 10. 如何获取和发送位置(即使应用程序被终止或暂停)服务器
- 11. 如何发送Android应用程序的位置到服务器?
- 12. Android - 设置应用程序背景
- 13. 将应用程序背景前置
- 14. 如何在城域应用程序中设置页面背景
- 15. 如何在Android中为整个应用程序设置背景?
- 16. iPhone - 将应用程序发送到背景
- 17. 发送应用程序到iphone上的背景
- 18. 如何在应用程序终止时保存应用程序的状态?
- 19. 如何在Nginx的配置SSL终止与Rails应用程序
- 20. 应用程序终止后发送本地通知
- 21. 如何从AlertDialog终止应用程序?
- 22. 如何将应用程序背景设置为与当前背景相同?
- 23. iPhone应用程序背景超时
- 24. 即使应用程序被杀害/终止,位置更新
- 25. 应用程序终止状态中的位置更新webservice
- 26. 当应用程序变为背景时,服务已停止
- 27. 当应用程序转到背景时停止AVAudioPlayer音乐
- 28. 如何在eclipse中调试时终止android应用程序
- 29. 如何在应用程序被终止时请求数据?
- 30. 如何在终止时运行快速应用程序?
你想发送经度和纬度?要么 ? – 2014-11-03 05:30:21
雅经纬度到服务器 – 2014-11-03 05:31:09
请帮我怎么做 – 2014-11-03 05:36:49