Posts Tagged Objective-C

Could not send unregistration request to daemon

During a debug process have you seen any of the following lines in your debugger/console logs?

void CLClientInvalidate(__CLClient*)",could not send unregistration request to daemon

or…

CLClientRegister: could not send registration request to daemon

If so, you’ve probably already seen this Apple support link:  http://discussions.apple.com/message.jspa?messageID=8408930

Well, I’m just going to validate a few things here for you.  (Before continuing this… check your code after briefly reading this blog.

  1. You will have to restore your iPhone.  (This is the solution that worked for me).  Please post a comment if you find a better solution.
  2. If you are coding using CLLocationManager you will more than likely notice that you only get 1 set of GPS values before the message starts appearing.  Also, the CLLocationManager startUpdatingLocation method will only call your delegate once.  (That is what was happening on my iPhone).
  3. If you dig through your iPhones “crash logs” via the Organizer application, you’ll more than likely witness that many applications are crashing.

I tried a multitude of workarounds and the only thing that sadly worked was a “restore” which took over 1 hour to complete.  I will say this, my iPhone runs a lot faster now!

, , , , ,

8 Comments

iPhone Network Connectivity Test Example

Every iPhone developer that has integrated a network connection based application has had to follow the Apple HID (Human Interface Design) rules. This means, that in order to get the Apple reviewers to sign-off on your application, you have to pass the network connectivity test. Basically, in the case of a catastrophic network disconnect issue with 3G and WiFi does your application properly alert the user that it will not perform properly without the usage of the network? I’ve seen a lot of workaround techniques where users attempt to do an HTTP GET on say Google or some other website. Clearly, this kind of technique will work sporadically in an unknown environment common to the mobile device. I mean, imagine causing your application users to sit through a 5-30 second web request timeout. The end-user will probably believe that the application is hung. The ideal solution happens to be handed to us in the API Framework SCNetworkReachability. (Make sure your codebase is linked properly with the “SystemConfiguration” Framework).
It’s worked for me and I recommend it for doing a simple network connectivity test.

#import <sys/socket.h>
#import <netinet/in.h>
#import <arpa/inet.h>
#import <netdb.h>
#import <SystemConfiguration/SCNetworkReachability.h>
//Snip, you know we're in the implementation...
- (BOOL) connectedToNetwork
{
	// Create zero addy
	struct sockaddr_in zeroAddress;
	bzero(&zeroAddress, sizeof(zeroAddress));
	zeroAddress.sin_len = sizeof(zeroAddress);
	zeroAddress.sin_family = AF_INET;
 
	// Recover reachability flags
	SCNetworkReachabilityRef defaultRouteReachability = SCNetworkReachabilityCreateWithAddress(NULL, (struct sockaddr *)&zeroAddress);
	SCNetworkReachabilityFlags flags;
 
	BOOL didRetrieveFlags = SCNetworkReachabilityGetFlags(defaultRouteReachability, &flags);
	CFRelease(defaultRouteReachability);
 
	if (!didRetrieveFlags)
	{
		return NO;
	}
 
	BOOL isReachable = flags & kSCNetworkFlagsReachable;
	BOOL needsConnection = flags & kSCNetworkFlagsConnectionRequired;
	return (isReachable && !needsConnection) ? YES : NO;
}
 
//call like:
-(void) start {
	if (![self connectedToNetwork]) {
                UIAlertView *alert = [[UIAlertView alloc] 
                         initWithTitle:@"Network Connection Error" 
                         message:@"You need to be connected to the internet to use this feature." 
                         delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
		[alert show];
		[alert release];
        } else {
             //do something 
        }
}

This code can also be found on this forum post.

, , , ,

16 Comments