I am new in Today Extension Widget Any one tell me how to call a web service using button on today Extenstion widget? How can i call it? is it use the class used for calling webservice from my Main app to call even if the app is in closed state or minimise state? This how my widget expect to be.
|=========================================|
| |
| MY TODAY WIDGET API CALL |
| ---------------- |
| | CALL API | |
| ---------------- |
| |
|=========================================|
I have to call an API on pressing button on it having following parameter
1)username 2)userpassword 3)user mobile number 4)user latitude 5)user longitude 6)accuracy 7)type
-(void)CallApi
{
NSString * devUrl = [NSString stringWithFormat:@"http://www.myhost.com/api/login?username=%@&password=%@&mobileno=%@,&latitude=%@&longitude=%@&accuracy=%@&type=%@",user_Name,password,mobile_Number,latitudeString,longitudeString,accuracyString,@"login"];
connection *new_connection;
new_connection = [[connection alloc] init];
[new_connection setHttp_delegate:self];
[new_connection make_request:devUrl];
}
#pragma mark -
#pragma mark http delegate
- (void) httpConnection:(connection *)connect didReciveresponse:(NSUInteger)errorCode
{
NSLog(@"errorCode%i",errorCode);
}
- (void) httpConnection:(connection *)connect didFinishWithLoadingData:(NSData*)data
{
[[UIApplication sharedApplication] endIgnoringInteractionEvents];
NSString* responseString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
if([responseString rangeOfString:@"nil"].location != NSNotFound)
{
NSString * newResponse = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
responseString = newResponse;
}
NSLog(@"%@",responseString);
}