I recently Developed a Applicaiton.Now i want to integrate Google and Youtube in this Applicaton like This Application.After doing a lot of search finally i think there are two methods through which we can integrate google and youtube for Customkeyboard.
First Approach (which is perfect Solution but it look extremly Difficult) is that if we open google url in Webview and then here is method which show customkeyboard when we Click in Google SearchBar.Beacuse when we used customkeyboard in applicaiton then we call it through (textView.inputView =Customkeyboard;) But for Google Searchbar how to used this Method looks Difficult task, if some one guide me about this Method i will be highly appriated.
Second Approach Which is not perfect but looks good is that if we enter text in UITextField and UITextView using Custom keyboard,then appened this Text to Google Search url as i did for Default keyboard`
-(IBAction)openBrowser {
NSString *parameter = @"NewYork";
NSString *url = @"https://www.google.com/search?q=";
NSString *searchingurl = [NSString stringWithFormat:@"%@%@", url, parameter];
UIApplication *app = [UIApplication sharedApplication];
[app openURL:[NSURL URLWithString:searchingurl]];
}
The Above url open a desired page for me .So using this approach i tried it for custom keyboard as my Below Code show
-(void)openBrowser {
NSString *parameter = @"انڈیا";
NSString *url = @"https://www.google.com.pk/search?hl=ur&tbo=d&noj=1&q=";
NSString *searchingurl = [NSString stringWithFormat:@"%@%@", url, parameter];
NSLog(@"searchingurl result:%@",searchingurl);
UIApplication *app = [UIApplication sharedApplication];
[app openURL:[NSURL URLWithString:searchingurl]];
}
But this time it dosn't open the Desired page Because Google directly unable to Recognize the Custom keyboard word which is (انڈیا),Now after that when i Combine the whole url (https://www.google.com.pk/search?hl=ur&tbo=d&noj=1&q=انڈیا) and open it in my Computer browser i get the Result (https://www.google.com.pk/search?hl=ur&tbo=d&noj=1&site=webhp&source=hp&q=%D8%A7%D9%86%DA%88%DB%8C%D8%A7&oq=%D8%A7%D9%86%DA%88&gs_l=hp.1.0.0l10.10727.35473.0.37372.5.4.1.0.0.0.304.1162.2-3j1.4.0...0.0...1c.3j4j1.PBbmxkMVaqc) Now in this url words(انڈیا) is Disappear and Browser translate it in some type of Code.Finaly when i used the Below Code
-(void)openBrowser {
// NSString *parameter = @"انڈیا";
NSString *searchingurl = @"https://www.google.com.pk/search?hl=ur&tbo=d&noj=1&site=webhp&source=hp&q=%D8%A7%D9%86%DA%88%DB%8C%D8%A7&oq=%D8%A7%D9%86%DA%88&gs_l=hp.1.0.0l10.10727.35473.0.37372.5.4.1.0.0.0.304.1162.2-3j1.4.0...0.0...1c.3j4j1.PBbmxkMVaqc";
//NSString *searchingurl = [NSString stringWithFormat:@"%@%@", url, parameter];
NSLog(@"searchingurl result:%@",searchingurl);
UIApplication *app = [UIApplication sharedApplication];
[app openURL:[NSURL URLWithString:searchingurl]];
}
it Works fine in iphone and open the Desired page.Now i want that if i used this Second Approach then Some can Guide me that how we can Directly open the url after appending Custom keyboard text like this url(https://www.google.com.pk/search?hl=ur&tbo=d&noj=1&q=انڈیا) or there is some method through which we can convert this url in Coding within applicaton in this formate https://www.google.com.pk/search?hl=ur&tbo=d&noj=1&site=webhp&source=hp&q=%D8%A7%D9%86%DA%88%DB%8C%D8%A7&oq=%D8%A7%D9%86%DA%88&gs_l=hp.1.0.0l10.10727.35473.0.37372.5.4.1.0.0.0.304.1162.2-3j1.4.0...0.0...1c.3j4j1.PBbmxkMVaqc) and then open this url in Google.Any help or Suggestion will be highly Appriated.thanks in Advance.
the browser encodes انڈیا with UTF8, this is %D8%A7%D9%86%DA%88%DB%8C%D8%A7 then.
Try this:
NSString *parameter = @"انڈیا";
NSString *url = @"https://www.google.com.pk/search?hl=ur&tbo=d&noj=1&q=";
NSString *searchingurl = [NSString stringWithFormat:@"%@%@", url, parameter];
NSString *encodedSearchingurl = [searchingurl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSLog(@"searchingurl result:%@",encodedSearchingurl);
UIApplication *app = [UIApplication sharedApplication];
[app openURL:[NSURL URLWithString:encodedSearchingurl]];