Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 09-09-2009, 02:15 PM   #1 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 5
Default iphone gps system

Guys-
Is the gps on by default? if we are creating an app that interacts with the gps, is the gps always on or how do we make sure its always ON automatically??

Many TIA
expertadvisor is offline   Reply With Quote
Old 09-09-2009, 02:46 PM   #2 (permalink)
Humbled Student
 
Dutch's Avatar
 
Join Date: Apr 2009
Location: Long Island, NY
Age: 32
Posts: 883
Send a message via AIM to Dutch
Default

Quote:
Originally Posted by expertadvisor View Post
Guys-
Is the gps on by default? if we are creating an app that interacts with the gps, is the gps always on or how do we make sure its always ON automatically??

Many TIA
define "ON"... In other words, when your app loads and you want to use the GPS, you need to request permission from the user using something like this

Code:
	locmanager = [[CLLocationManager alloc] init]; 
	[locmanager setDelegate:self]; 
	[locmanager setDesiredAccuracy:kCLLocationAccuracyBest];
	[locmanager startUpdatingLocation];
Once you call startUpdatingLocation, the user will be asked whether or not to allow your app access to GPS data.

If they click NO you get an error
Code:
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error { 
	NSLog(@"Error Encountered");
}

if they click YES, you must handle it in the following code:
Code:
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation 
{ 

	if (wasFound) return; 
	
	numberOfLocationUpdates++;
	
	NSDate* newLocationEventTime = newLocation.timestamp;
	NSTimeInterval howRecentNewLocation = [newLocationEventTime timeIntervalSinceNow];
	
	// filter cached and previous locations
	if ((!currentLocation || currentLocation.horizontalAccuracy >= newLocation.horizontalAccuracy) && (howRecentNewLocation < -0.0 && howRecentNewLocation > -10.0))  {
		if (currentLocation) {
			[currentLocation release];
		}
		currentLocation = [newLocation retain];
	}
	
	if (currentLocation  || numberOfLocationUpdates >= 15) {
		[locmanager stopUpdatingLocation];

		numberOfLocationUpdates = 0;
		//Use newLocation here
	}

}
Dutch is offline   Reply With Quote
Old 09-09-2009, 04:28 PM   #3 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 5
Default gps and autostart app

Wow, thanks.
generically, trying to figure out if I can auto launch an app to run that uses gps all the time, one that people can not turn off or disable without a password.
expertadvisor is offline   Reply With Quote
Old 09-09-2009, 04:36 PM   #4 (permalink)
Humbled Student
 
Dutch's Avatar
 
Join Date: Apr 2009
Location: Long Island, NY
Age: 32
Posts: 883
Send a message via AIM to Dutch
Default

Quote:
Originally Posted by expertadvisor View Post
Wow, thanks.
generically, trying to figure out if I can auto launch an app to run that uses gps all the time, one that people can not turn off or disable without a password.
That would be a negative. When it comes to permissions and such, your app is 'the intruder' and only it is subject to limitations on the locationManager. If the user wants to turn it off, all they need to do is press the home button and close your app.
Dutch is offline   Reply With Quote
Reply

Bookmarks

Tags
gps, iphone

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 247
21 members and 226 guests
ADY, beleg_1998, Dani77, diyora, FAED, fredidf, F_Bryant, iDifferent, JamesCahall, JasonR, mer10, Oral B, prchn4christ, smithdale87, Speed, spiderguy84, stekki, tgjorgoski, Touchmint, twerner, vigu360
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,880
Threads: 89,228
Posts: 380,755
Top Poster: BrianSlick (7,129)
Welcome to our newest member, @sandris
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:09 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0