Skip to content

Instantly share code, notes, and snippets.

@MSch
Created May 26, 2011 21:29
Show Gist options
  • Save MSch/994130 to your computer and use it in GitHub Desktop.
Save MSch/994130 to your computer and use it in GitHub Desktop.
-(void)pingAnalytics:(NSString*)action {
NSMutableString* params = [NSMutableString stringWithFormat:@"uuid=%@",[self getUUID]];
#ifdef BETA
[params appendString:@"&beta=1"];
#endif
NSString* url = [NSString stringWithFormat: @"https://update.appscape.at/degrees/%@?%@", action, params];
NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]];
[request setHTTPMethod:@"GET"];
[[NSURLConnection connectionWithRequest:request delegate:self] retain];
}
-(NSString*)getUUID {
NSString* result = @"unknown";
io_registry_entry_t ioRegistryRoot = IORegistryEntryFromPath(kIOMasterPortDefault, "IOService:/");
CFStringRef uuid = IORegistryEntryCreateCFProperty(ioRegistryRoot, CFSTR(kIOPlatformUUIDKey), kCFAllocatorDefault, 0);
IOObjectRelease(ioRegistryRoot);
if (uuid) {
result = [NSString stringWithString:(NSString *)uuid];
CFRelease(uuid);
}
return result;
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
[connection release];
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
[connection release];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment