Am I adding URL correctly to SLComposeViewController - objective-c

-(void) vPostStuffs:(UIViewController *) parent withImage:(UIImage *) image andText:(NSString *) text andURL: (NSString *) URL
{
// Create a compose view controller for the service type Twitter
SLComposeViewController *mulitpartPost = [SLComposeViewController composeViewControllerForServiceType:self.strSLServiceType];
if (text)
{
[mulitpartPost setInitialText:text];
}
if (URL)
{
[mulitpartPost addURL:[NSURL URLWithString:URL]];
}
if (image)
{
[mulitpartPost addImage:image];
}
[parent presentViewController:mulitpartPost animated:YES completion:nil];
}
In Android, facebook will display a screen shot of URL instead of simply writing the URL in the post. In my iOS application, facebook simply display the URL
What am I missing?
Is this related to Facebook SLComposeViewController URL shows up in body if both URL and image present
Here is the thing. If I do not display the image, if I get rid [mulitpartPost addImage:image]; then the URL doesn't show up as anything.
In twitter, URL and pictures do not show up. Even though after pressing post it does shows up on the twitter.
In facebook, URL screenshot never shows up no matter what even though it shows up after posting.
In twitter, those with multiple twitter accounts will have twitter post to the wrong account.

Related

UIWebView, can a button on a page trigger an app's view change?

I load up a UIWebView in my app which displays html text and a sign out button.
Is it at all possible that when the user taps the html button it can then change the view? ie: it will go back in navigation of the app to the previous view?
Any examples of this being done?
Can this also be done in java for my Android version?
Edit: If I place an event using JS or something on the button can I then use a listener within the app's web view to go back a view?
What you could do is...
When one of your buttons is pressed, it actually attempts to send the user to a new URL (eg, through a href="", or javascript redirect). But, in your app's code you can use UIWebView's delegate methods to intercept the loading of the URL and instead run some app-based code.
Eg.
- (BOOL) webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
NSString *_url = [NSString stringWithFormat:#"%#", request.URL];
if ([_url rangeOfString:#"?signout"].location != NSNotFound) {
[self userRequestsLogout];
return NO;
}
return YES;
}
Don't forget that UIWebView also has;
- (NSString *)stringByEvaluatingJavaScriptFromString:(NSString *)script
Hopefully this helps.

How to display iOS 6 Facebook alert view without first showing SLComposeViewController

In iOS 6, when you create an SLComposeViewController and show it with presentViewController and you have not called isAvailableForServiceType first, you will get the "No Facebook Account" alert view which gives the user an opportunity to set up their account in Settings.
Unfortunately it also shows the native Facebook posting dialog in the background as well.
I would like to have a cleaner experience than popping up two dialogs at the same time, so is there a way to only show the "No Facebook Account" dialog on its own after checking availability with isAvailableForServiceType?
Here's basically what I'd like to do:
// Check to see if the user has a Facebook account set up...
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
SLComposeViewController *vc = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
SLComposeViewControllerCompletionHandler completionBlock = ^(SLComposeViewControllerResult result){
// do something when complete...
};
[vc setCompletionHandler:completionBlock];
[vc setInitialText:#"Intital text..."];
[self presentViewController:vc animated:YES completion:nil];
} else {
// No Facebook account configured yet,
// so show "No Facebook Account" alert view here.
}
Is this even possible, or will I just need to show a vanilla UIAlertView that tells the user to go to the Settings app and set up their Facebook Account?
BTW, I'm also guarding that block with a call that determines if this device even supports the use of SLComposeViewController, and if not, uses the Facebook SDK instead...
I wish it could be easy!! For now i was able to call the composeViewControllerForServiceType: method even without the account setup so it will show the alert with the settings button, hide the view but i couldn't be able to hide the keyboard!! Maybe you could find a way to reset the UITextFieldDelegate or whatevere esle to not show the keyboard...but I'm not sure! Let me know if you could figure it out!

How Judgment webview page is loaded?

How Judgment webview page is loaded? Let me tell you the page is loading.
Also, unable to open web pages loaded in Webview, like some of the below URLs.
- (void)awakeFromNib {
NSString *urlString = #"http://www.google.com";
// Insert code here to initialize your application
[[_webView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlString]]];
}
- (IBAction)googleOpen:(id)sender {
[_webView setMainFrameURL:#"http://www.google.com"];
}
- (IBAction)baiduOpen:(id)sender {
[_webView setMainFrameURL:#"http://www.baidu.com"];
}
- (IBAction)yahooOpen:(id)sender {
[_webView setMainFrameURL:#"http://www.yahoo.com"];
}
How can I open a URL with a way to pass parameters?
If you want to know when a website has loaded, link the WebFrameLoadDelegate protocol, and implement webView:didFinishLoadForFrame: to know if the webpage has loaded.
Use webView:didStartProvisionalLoadForFrame: to know if the webpage has start loading.
Check your connection to the internet, and see if you can open the websites from another web browser. If it works, then check if your IBAction's are linked correctly to your buttons.
What do you mean by open a URL with parameters? If you mean by having a textfield which allows users to search keywords on certain websites such as Google, just do http://www.google.com/search?q=%yoursearch, replacing %yoursearch with the users input.

Launch Facebook page with scheme?

In my app I have a button. Pressing the button takes me to the Facebook app with the scheme: fb://. But I want to have a scheme to link to my facebook page. fb://page/MYPAGENAME doesn't work or am I doing it wrong? Help is much appreciated!
Edit
This is what the method looks like now:
- (IBAction)facebookButton:(id)sender
{
NSURL *url = [NSURL URLWithString:#"fb://MYPAGENAME"];
[[UIApplication sharedApplication] openURL:url];
}
I've added a username to my page now.

How to connect web url in iphone application development?

I am new to iphone application.I have 6 uiimages in a view.fifth image is facebook and sixth one is twiter.Under images,Iplaced two roundrectbuttons named as click5 and click6. My requirement is,when i click on those images,I have to go to login pages of facebook and twitter.how can i do this?can anyone send me sample example and explain it detai?
If you want to send the user to the website using Safari, you invoke the openURL: method in the UIApplication class, like this:
NSURL *facebookURL = [NSURL URLWithString:#"http://www.facebook.com"];
[[UIApplication sharedApplication] openURL:facebookURL];
When assigning a button to an action, you use the UIButton's addTarget:action:forControlEvents:, providing an event handler as action. Say you're setting this up in viewDidLoad, it might look like this:
- (void) viewDidLoad {
[myButton addTarget:self
action:#selector(btnClicked:)
forControlEvents:UIControlEventTouchUpInside];
}
/**
* Click/tap event handler for some buttons
*/
- (IBAction) btnClicked:(id)sender {
// Check which button was pressed.
if (sender == self.click5) {
// ...
}
else if (sender == self.click6) {
// ...
}
}
You know the very easiest way to do this? With the free 3rd party component ShareKit. It wraps the Facebook and Twitter (and several other social network) APIs to literally make it a three-line deal to post things.
I used it for the first time in the last app I built and I was SHOCKED at how easy to use it was.