How to disable skype call button in webview when user is disconnected?

I am using Skype integration in my iPhone application using html. When I load the page, it will show whether the user will be online or offline. When I press the ONLINE button, my application will be closed and Skype will open. But when I press the OFFLINE button, it will happen the same as above. I used the following code to create the skype button in webview, to show the online status of the user in skype mode and to call Skype.

<a href="skype:arafa_futbal?call"> <img src="http://mystatus.skype.com/smallclassic/arafa_futbal" style="border: none;" width="114" height="20" alt="My status" /> </a> 

My question is: how to disable webview when the user is disconnected?

i.e., if I press the OFFLINE button, it should not do anything.

+6
source share
2 answers

This will solve ur problem. Call url http://mystatus.skype.com/arafa_futbal.xml in nsurlconnection and get xml data and analyze it to get skype user status

 NSURL *url = [NSURL URLWithString:@"http://mystatus.skype.com/arafa_futbal.xml"stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url]; [req addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"]; [req addValue:0 forHTTPHeaderField:@"Content-Length"]; [req setHTTPMethod:@"GET"]; conn = [[NSURLConnection alloc] initWithRequest:req delegate:self]; if (conn) { webData = [[NSMutableData data] retain]; } -(void) connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response{ [webData setLength:0]; } -(void) connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{ [webData appendData:data]; } -(void) connectionDidFinishLoading:(NSURLConnection *) connection { xmlParser = [[NSXMLParser alloc] initWithData:webData]; [xmlParser setDelegate:self]; [xmlParser setShouldResolveExternalEntities:YES]; [xmlParser parse]; } -(void) parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict { } -(void) parser:(NSXMLParser *)parser foundCharacters:(NSString *)string { if ([string isEqualToString:@"Offline"]) { webview.userinteractionEnabled = NO; } if ([string isEqualToString:@"Online"]) { webview.userinteractionEnabled = YES; } } 
0
source

Do you have control over HTML? If so, use http://mystatus.skype.com/arafa_futbal.xml to decide whether to create a Skype link or not.

One caveat: I donโ€™t know if I always had โ€œAllow my online status to be displayed on the Internetโ€, or if it was by default, but it doesnโ€™t work for me unless I turn over the โ€œPrivacyโ€ section.

Unless you have control over HTML, I don't know how to do this with UIWebView.

+1
source

All Articles