开发者

Start GPS Application As a Service

开发者 https://www.devze.com 2023-01-23 14:46 出处:网络
(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

// Override point for customization after application launch.

locmanager = [[CLLocationManager alloc] init]; 
[locmanager setDelegate:self]; 
[locmanager setDesiredAccuracy:kCLLocationAccuracyHundredMeters];
[locmanager setDistanceFilter:10];
[locmanager startUpdatingLocation];

[window makeKeyAndVisible];

return YES;
}

- (voi开发者_StackOverflowd)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation       *)newLocation fromLocation:(CLLocation *)oldLocation 
{ 

CLLocationCoordinate2D loc = [newLocation coordinate];
latitude = [NSString stringWithFormat: @"%f", loc.latitude];
longitude= [NSString stringWithFormat: @"%f", loc.longitude];
//Call to the web service for sending data

}

Will it be possible to start this application automatically when the phone starts.I don't want users to start this.


No, the only way for your application to start is for a user to start it, either by tapping on it on the home screen, or by opening it through a push notification.

CoreLocation runs in the background as part of iOS, but your app can only access that data when it is open. If it is running in multitasking mode, I imagine that you'd be able to access location data through a background task.

Note that a "Location" indicator will appear in the status bar on the right whenever you use Core Location. This is done for privacy reasons.


No. Not unless it's jailbroken.

0

精彩评论

暂无评论...
验证码 换一张
取 消