I have made an app and I want to create a UIButton that shares this app with facebook users.
I wrote the following code:
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[controller setInitialText:#"My App Name"];
[controller addURL:[NSURL URLWithString:#"https://itunes.apple.com/il/app/fruit-ninja-free/id403858572?mt=8/"]];
[self presentViewController:controller animated:YES completion:Nil];
}
else {
}
I've used an example URL of the famous fruit ninja cause my app is not yet on the app store and doesn't have it's own URL.
The issue:
If the app is not yet on iTunes, I don't have an iTunes URL to share yet... So how do I share my app?
Help is much appreciated...
You should create stub for your app at iTunes Connect. After that you'll be able to get link to your application even before submission.
Related
I am having Facebook login in my iOS App. After following all the steps from developer.facebook.com and successful integration I can see a button in my view on clicking that button it redirects to safari and asking for fb username and password but after logging in it shows 'App Not Setup' error. Here I have 3 questions
I want everything to load inside the app itself
I don't want the FB login button, I want to load the FB page on viewdidload/appear
Whats the reason for "App not Setup" error. I want to test with successful loginenter
There might be various reasons for "App not setup" like
Check your plist file where you are entering 'FacebookAppID' and URL string
a)check your facebook app id
b)check your URL String facebook app id has prefix 'fb'
c)Check your bundle id i.e com.yourapp.com is properly set on facebook app settings or not.
d) Check you have entered all correct information in app settings of your facebook app.
If you don't strictly need to use Facebook SDK you could use the Social.framework. That way you wouldn't have to worry about the bundle id or Facebook App ID.
Here's a sample code to show how it works:
SLComposeViewController *slComposeViewController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[slComposeViewController setInitialText:MyText];
[slComposeViewController setTitle:MyTitle];
if (![slComposeViewController addURL:url]) {
NSLog(#"Unable to add url");
}
[self presentViewController:slComposeViewController animated:YES completion:nil];
//Check the result
slComposeViewController.completionHandler = ^(SLComposeViewControllerResult result)
{
switch (result) {
case SLComposeViewControllerResultCancelled:
//Do something
break;
case SLComposeViewControllerResultDone:
//Do something
break;
}
};
//If iOS < 7.0 dismiss the viewcontroller
NSString *version = [[UIDevice currentDevice] systemVersion];
if ([version floatValue] < 7.0)
{
dispatch_async(dispatch_get_main_queue(), ^{
[slComposeViewController dismissViewControllerAnimated:NO completion:^{
// Do something
}];
});
}
I have a little question about my Facebook integration in my App.
In my Simulator, it's all perfect, but if I am testing the app at my normal
IPhone (5) the Facebook post window don't open. I get no error or warnings but nothing happens.
Maybe you have any ideas, thank you!
Have a nice day!
//edit: my code
- (IBAction)postToFacebook:(id)sender {
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[controller setInitialText:#"First post from my iPhone app"];
[self presentViewController:controller animated:YES completion:Nil];
}
}
Just remove this check:
[SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]
Here is how your code should look like:
- (IBAction)postToFacebook:(id)sender {
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[controller setInitialText:#"First post from my iPhone app"];
[self presentViewController:controller animated:YES completion:Nil];
}
Apparently if you are not logged into Facebook (Settings -> Facebook) then it will return false on the iPhone but returns true on Simulator.
How can I build a login view in a tabbed application? I'm new in ios development. I have read a lot through the internet but no one just posts the code I can understand. Any help is appreciated =).
here is a related post here: Adding login screen in front of Cocoa Touch Tab Bar Application for IOS
I prefer writing like this tho.
[window setRootController:tabBarCon];
if (notLogedIn) {
loginViewController = [[InitialScreenViewController alloc] init];
[tabBarCon.view addSubview:loginViewController.view];
}
[window makeKeyAndVisible];
return YES;
- (bool)notLoggedIn {
//check if there is any sessions exists in local storage
}
If your content relates to the user account, remember to implement a method to reload the the content after login.
Finally I did This to solve my question:
My rootViewController is my registration view, then I set a button with implements a custom segue:
-(IBAction)button {
NSLog(#"username: %#, password: %#, passwordrt: %#", username.text, password.text, passwordrt.text);
[self performSegueWithIdentifier:#"tabBar" sender:self];
}
As you all may know, since iOS5 there is a native Twitter framework which make it easy to post tweets from your app.
Is there a way to prompt an alert that forwards the user to the settings app and ask for username and password?
I know that i could solve the problem with the following code:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"prefs:root=TWITTER"]];
But thats undocumented code..
Thanks in advance
Regards Billy
(My first post on SO)
In iOS5.1, we should use TWTweetComposeViewController to show the dialog since apple rejects apps using prefs:root=TWITTER.
But, I didn't like showing the tweet screen and keyboard
so I figured out the way to hide them, but show the pop up screen.
UPDATE:
Apple approved my app using this trick.
TWTweetComposeViewController *viewController = [[TWTweetComposeViewController alloc] init];
//hide the tweet screen
viewController.view.hidden = YES;
//fire tweetComposeView to show "No Twitter Accounts" alert view on iOS5.1
viewController.completionHandler = ^(TWTweetComposeViewControllerResult result) {
if (result == TWTweetComposeViewControllerResultCancelled) {
[self dismissModalViewControllerAnimated:NO];
}
};
[self presentModalViewController:viewController animated:NO];
//hide the keyboard
[viewController.view endEditing:YES];
//this approach doesn't work since you can't jump to settings
// [self dismissModalViewControllerAnimated:NO];
You don't need to implement this, if you set up your Twitter integration to make a post on Twitter and iOS detects that there is no Twitter account set up it will do this automatically for you!
This is a screenshot of one of my apps running on my iPhone 4S on iOS 5.1
The removal of Preferences links is in reference to custom actions by the developer, as in linking to your own preferences menu. This does not apply because not only is Twitter a built in function of iOS 5 but the UIAlertView that pops up to notify you isn't handled by the developer, it is an automatic function of iOS.
Here i found the way :
Display custom alert if no twitter account has been setup on your device settings:
if (![TWTweetComposeViewController canSendTweet]) {
UIAlertView *alertViewTwitter = [[[UIAlertView alloc]
initWithTitle:#"No Twitter Accounts"
message:#"There are no Twitter accounts configured. You can add or create a Twitter account in Settings."
delegate:self
cancelButtonTitle:#"Settings"
otherButtonTitles:#"Cancel",nil] autorelease];
[alertViewTwitter show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if (buttonIndex==0) {
TWTweetComposeViewController *ctrl = [[TWTweetComposeViewController alloc] init];
if ([ctrl respondsToSelector:#selector(alertView:clickedButtonAtIndex:)]) {
[(id <UIAlertViewDelegate>)ctrl alertView:alertView
clickedButtonAtIndex:0];
}
[ctrl release];
}
}
Hope this will make sense :)
It's not possible, although it should automatically ask the user to login, if the user isn't logged in already.
As of iOS 5.1 that feature has been removed, as seen here
I'm trying to post a simple url to facebook from within my Native iOS App. What I do is this:
facebook = [[Facebook alloc] initWithAppId:FB_APP_ID andDelegate:delegate];
then at some point
[facebook authorize:permissions];
at this point my app quits and it gets me to safari and to the permissions page instead of presenting me a login-dialog (inside my app) where I login and then hit post or something an just post to my wall.
I'm pretty sure this is a simple question but since this is the first time I'm doing facebook integration it is a pain for me configuring it and the docs don't help to much.
Any help is appreciated! Thanks!
If you definitely need to remove redirection to Safari or Facebook app, you should open the FBConnect Facebook.h class and find the following method:
- (void)authorizeWithFBAppAuth:(BOOL)tryFBAppAuth
safariAuth:(BOOL)trySafariAuth {
there you need to state that you do not want to be redirected anywhere, to do that set those two bools to NO
- (void)authorizeWithFBAppAuth:(BOOL)tryFBAppAuth
safariAuth:(BOOL)trySafariAuth {
tryFBAppAuth = NO;
trySafariAuth = NO;
Next, to post something to wall, you have two options. One is broken - the standard facebook dialog window, which will bring the keyboard BEHIND the actual webview once you show any UIAlertView ANYWHERE in your application, therefore do NOT use it. Instead use your own custom interface with a simple UITextView area and a push to wall outlet button. Here's the method that you'll need in order to post to wall from your custom view:
- (void)facebookPostToWallWithMessage:(NSString *)message {
sharedInstance.facebookDelegate = delegate;
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
message, #"message", // The status message
nil];
pushMessageRequest = [facebook requestWithGraphPath:#"me/feed"
andParams:params
andHttpMethod:#"POST"
andDelegate:self];
}
And here's the delegation methods that you'll need in order to inform users that they've posted an update or to inform them that it has failed:
- (void)request:(FBRequest *)request didLoad:(id)result {
if (request == pushMessageRequest) {
NSLog(#"message has been posted, inform delegate");
}
}
- (void)request:(FBRequest *)request didFailWithError:(NSError *)error {
if (request == pushMessageRequest) {
//failed to post message, inform delegate
//[facebookDelegate facebookFailedToPostToWallWithMessage:error.localizedDescription];
}
}