I am using NSString *strURL=[NSString stringWithFormat:"https://mytest.com/19"]
and allow [NSURLRequest setAllowsAnyHTTPSCertificate:YES forHost:[URL host]];
so manually login ..
Please let me know if i have multiples URL then how can ?
You can opt out security for all domains once by keeping above falg in info.plist Hope it can help you.
try this work for me:-
NSString *strURL1=[NSString stringWithFormat:#"https://32ewwrwrwerw/bxbbx/"];
NSString *strURL2=[NSString stringWithFormat:#"https://demo1/demo/"];
NSString *strURL3=[NSString stringWithFormat:#"https://demo2.com/demo2/"];
NSString *strURL4=[NSString stringWithFormat:#"https://demo3.com/demo3/"];
NSString *strURL5=[NSString stringWithFormat:#"https://xvxylsl.com/demo4/"];
NSURL *URL1 = [NSURL URLWithString:strURL1];
NSURL *URL2 = [NSURL URLWithString:strURL2];
NSURL *URL3 = [NSURL URLWithString:strURL3];
NSURL *URL4 = [NSURL URLWithString:strURL4];
NSURL *URL5 = [NSURL URLWithString:strURL5];
[NSURLRequest setAllowsAnyHTTPSCertificate:YES forHost:[URL1 host]];
[NSURLRequest setAllowsAnyHTTPSCertificate:YES forHost:[URL2 host]];
[NSURLRequest setAllowsAnyHTTPSCertificate:YES forHost:[URL3 host]];
[NSURLRequest setAllowsAnyHTTPSCertificate:YES forHost:[URL4 host]];
[NSURLRequest setAllowsAnyHTTPSCertificate:YES forHost:[URL5 host]];
NSString *strURL1=[NSString stringWithFormat:#"https://xcxcxc/121w321"];
NSString *strURL2=[NSString stringWithFormat:#"https://xbxnjkx/wjdjd/"];
NSString *strURL3=[NSString stringWithFormat:#"https://jwkjsjs/bxbxb/"];
NSString *strURL4=[NSString stringWithFormat:#"https://10.11.22.11/ggsgs/"];
NSString *strURL5=[NSString stringWithFormat:#"https://10.23.234.122/hhdd/"];
NSURL *URL1 = [NSURL URLWithString:strURL1];
NSURL *URL2 = [NSURL URLWithString:strURL2];
NSURL *URL3 = [NSURL URLWithString:strURL3];
NSURL *URL4 = [NSURL URLWithString:strURL4];
NSURL *URL5 = [NSURL URLWithString:strURL5];
[NSURLRequest setAllowsAnyHTTPSCertificate:YES forHost:[URL1 host]];
[NSURLRequest setAllowsAnyHTTPSCertificate:YES forHost:[URL2 host]];
[NSURLRequest setAllowsAnyHTTPSCertificate:YES forHost:[URL3 host]];
[NSURLRequest setAllowsAnyHTTPSCertificate:YES forHost:[URL4 host]];
[NSURLRequest setAllowsAnyHTTPSCertificate:YES forHost:[URL5 host]];
Related
i'm downloading my pdf file in document directory and then trying to show that pdf file
from that path to load in uiwebview but its not opening just a blank white page, i dont
understand why its not loading in uiwebview.
below is my code ,
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [documentsDirectory stringByAppendingPathExtension:#".pdf"];
NSURL *url = [NSURL fileURLWithPath:filePath];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[self.webView loadRequest:request];
and my filepath is:
NSLog(#"Filepath------->> %#", filePath);
/Users/zee/Library/Application Support/iPhone Simulator/6.0/Applications/BD79829B-95FF-4B91-94AD-830C6B1CD31D/Documents/myPDF.pdf
Please tell me why its not working and what should be the best solution
Thanks
Zeeshan Shaikh
Try this,
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [documentsDirectory stringByAppendingPathExtension:#"sample.pdf"];
NSURL *url = [NSURL fileURLWithPath:filePath];
NSString *urlString = [url absoluteString];
NSString *encodedString=[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *webURL = [NSURL URLWithString:encodedString];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[self.webView loadRequest:request];
So normally to load a UIWebView I do..
NSURL *url = [NSURL URLWithString:#"http://www.google.com"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[_webView loadRequest:request];
However, now I need to do this dynamically, depending on a table cell that a user clicks. I load the table cells from JSON and everything works fine. Now I need to get the "id" of the post in the cell, and load it dynamically. Currently I've tried this but it doesn't work...
NSURL *url = [NSURL URLWithString:#"http://www.google.com/story.php?id="];
url = [NSURL URLWithString:storyId relativeToURL:url];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[_webView loadRequest:request];
Any tips?
Why don't you just format the URL string?
NSURL *url = [NSURL URLWithString:[NSString
stringWithFormat:#"http://www.google.com/story.php?id=%#", storyId]];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[_webView loadRequest:request];
I am working on my new iPhone application,in that I need the datas and addresses from one url and from anther url I need to get the images. These two results are in the form of json response data but I am getting only the result for the datas....
Here is my code
- (void)viewDidLoad
{
jsondataimg=[[NSMutableString alloc] initWithString:#""];
#####for this url i'm not getting the result##########
NSString *urlimg = [NSString stringWithFormat:#"https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=%#",name];
//NSLog(#"%#",urlimg);
NSURL *url1= [NSURL URLWithString:urlimg];
NSURLRequest *request1 = [[NSURLRequest alloc] initWithURL: url1];
NSURLConnection *connection1 = [[NSURLConnection alloc] initWithRequest:request1 delegate:self];
jsonData = [[NSMutableString alloc] initWithString:#""];
NSString *urlString = [NSString stringWithFormat: #"https://maps.googleapis.com/maps/api/place/details/json?reference=%#&sensor=false&key=your key",selectedname];
NSLog(#" the name is%#",selectedname);
NSLog(#" the reference is%#",selectedrefer);
NSURL *url = [NSURL URLWithString:urlString];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL: url];
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
[connection release];
[request release];
[connection1 release];
[request1 release];
[super viewDidLoad];
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
NSString *partialData = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSString *partialData1 = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
[jsondataimg appendString:partialData1];
[jsonData appendString:partialData];
[partialData release];
[partialData1 release];
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
# pragma mark for fetching the image urls
NSDictionary *imageurls=[jsondataimg JSONValue];
NSDictionary*images=[imageurls objectForKey:#"responseData"];
NSLog(#"%#",images);
##########here null value is displaying#######
#pragma mark for fetching the datassss
NSDictionary *filesJSON = [jsonData JSONValue];
NSDictionary *address1 = [filesJSON valueForKey:#"result"];
NSLog(#"Found %#",address1);
}
Just use this no need to set delegate methods nsurl connections.. you will get the data...and same for next one.
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:#"https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=mumbai"]]];
NSURLResponse *response;
NSError *error;
NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
NSString *strResponse = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
// NSLog(#"%#",strResponse);
SBJSON *sbJason = [[SBJSON alloc] init];
NSMutableDictionary *getPlaceList = [sbJason objectWithString:strResponse];
I would like to know if it's possible to play a video from an NSData object... with the MPMoviePlayerController.
Ben's answer works perfectly on simulator but wont work on the device, You cannot write anywhere on the device. Check code below
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:#"myMove.mp4"];
[videoData writeToFile:path atomically:YES];
NSURL *moveUrl = [NSURL fileURLWithPath:path];
player = [[MPMoviePlayerController alloc]init];
[player setContentURL:moveUrl];
player.view.frame = viewPlayer.bounds;
[viewPlayer addSubview:player.view];
[player play];
As far as I know this is not possible. If the data comes from your DB, can you save it into a temporary file and play that?
It is better to use NSFileManager in this case instead writeToFile
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:#"myMove.mp4"];
[[NSFileManager defaultManager] createFileAtPath:path contents:videoData attributes:nil];
NSURL *moveUrl = [NSURL fileURLWithPath:path];
player = [[MPMoviePlayerController alloc]init];
[player setContentURL:moveUrl];
player.view.frame = viewPlayer.bounds;
[viewPlayer addSubview:player.view];
[player play];
create a file with the type of your NSData for example if your NSData is type of mp4 create a file with that type - for example - "myMove.mp4"
copy past the file to your app resurces
add this code
NSData *mediaData; //your data
NSString *movePath=[[NSBundle mainBundle] pathForResource:#"myMove" ofType:#"mp4"];
[mediaData writeToFile:movePath atomically:YES];
NSURL *moveUrl= [NSURL fileURLWithPath:movePath];
MPMoviePlayerController *movePlayer=[[MPMoviePlayerController alloc]init];
[movePlayer setContentURL:moveUrl];
[movePlayer play];
My Requirement: I want to send login details(email, password) to server, have to maintain session for valid username.
How to create & maintain a session using "NSURLConnection" of iphone SDK?
If you found any Tutorials/Code snippets on this issue,Please post the corresponding linke here.
Advance thanks for your help.
NSString *urlString = [NSString stringWithFormat:#"http://www.mywebsite.com/login.php?email=username#yahoo.com&pwd=pass"];
NSURL *url = [NSURL URLWithString:urlString];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL: url];
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
[connection release];
[request release];