UIActivityViewController not Working With Facebook Login - iphone

I am using UIActivityViewController in my new app for Facebook Share Option.
But if the user not login to the device, it dont working.. When select setting, Login page not appearing..
IActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
activityVC.excludedActivityTypes = #[UIActivityTypeAssignToContact, UIActivityTypePrint];
[self presentViewController:activityVC animated:TRUE completion:nil];
What can i do on this..? Is that the Problem of my code or a Common Error..?

iOS 6 introduced both the UIActivityViewController class and Social Framework, both of which may be used to integrate Twitter, Facebook and Sina Weibo functionality into iOS 6 applications. For general purpose requirements, the UIActivityViewController and SLComposeViewController classes provide an easy to implement path to social network integration.
UIActivityViewController *activityController =[[UIActivityViewController alloc]initWithActivityItems:activityItems applicationActivities:nil];
self presentViewController:activityController animated:YES completion:nil];
In order to use the SLComposeViewController class, a number of steps should be performed in sequence. Firstly, the application may optionally check to verify whether a message can be sent to the specified social network service. This essentially equates to checking if a valid social network account has been configured on the device and is achieved using the isAvailableForServiceType: class method, passing through as an argument the type of service required from the following options:
SLServiceTypeFacebook
SLServiceTypeTwitter
SLServiceTypeSinaWeibo

this is how you start ActivityIndicatorView with Loading lable
UIActivityIndicatorView *tempSpinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
lable =[[UILabel alloc]init];
lable.center = self.view.center;
lable.text = #"Loading...";
lable.hidden=NO;
lable.backgroundColor = [UIColor clearColor];
lable.textColor = [UIColor blackColor];
[lable sizeToFit];
lable.center = CGPointMake(160, 255);
tempSpinner.center = self.view.center;
[self.view addSubview:tempSpinner];
[self.view addSubview:lable];
start where ever you want like this
[tempSpinner startAnimating];
stop it like this where ever you want
[tempSpinner stopAnimating];
hide unhide loading label as per requirement

Related

Missing image when shared using UIActivityViewController

We've the following method to share content in the application. For each content we share:
Text
Image
URL
+ (void) generalShare:(NSString *) text withEntity:(SMEntity *) theEntity onView:(UIViewController*) theViewController withImage:(UIImage *) image completion:(void (^)(void))completion
{
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:templateURL
, [SMSocialManager getAction:theEntity]
, [theEntity getId]]];
NSArray *sharingItems = #[text, url, image];
UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:sharingItems applicationActivities:nil];
[activityController setValue:text forKey:#"subject"];
[UINavigationBar appearance].barStyle = UIBarStyleBlack;
[UINavigationBar appearance].translucent = NO;
[UINavigationBar appearance].barTintColor = UIColorFromRGB(SMPrimaryColor);
[theViewController presentViewController:activityController animated:YES completion:^{
return completion();
}];
}
Until a few time it works perfectly, a few time ago the text was missing when you try to share in facebook (based on the new policy) but just a days ago the image, is also missing, and just the URL is included.
Any suggestions?
I could figure out generating an ad-hoc solution for each destination social network, but find a way to solve with an standard solution could be better approach.
Thank you!
It seams facebook and instagram removed the caption from the integration, and I don't know why but with facebook also the image is not working anymore.

Why is my AdMob code leaking in my iphone app?

I have included AdMob in my iphone app. I have the following code in my viewDidLoad method:
bannerView_ = [[GADBannerView alloc]
initWithFrame:CGRectMake(0.0,
0.0,
320,
50)];
// Specify the ad's "unit identifier." This is your AdMob Publisher ID.
bannerView_.adUnitID = ADMOB_BANNER_UNIT_ID;
// Let the runtime know which UIViewController to restore after taking
// the user wherever the ad goes and add it to the view hierarchy.
bannerView_.rootViewController = self;
[self.view addSubview:bannerView_];
// Initiate a generic request to load it with an ad.
GADRequest *r = [[GADRequest alloc] init];
r.testing = YES;
[bannerView_ loadRequest:r];
[r release];
This leaks. When I comment out the second last line ( [bannerView_ loadRequest:r]; ), the leak disappears. The only thing I changed in this code from the example provided by Google was to introduce the variable r so I could put AdMob in testing mode. In the code supplied by Google, bannerView_ is released by viewDidUnload. I looked for the loadRequest method but all I found was a definition in the GADBannerView.h file. As far as I can tell, there is no GADBannerView.m file, which seems weird in itself. Anyway, any tips would be much appreciated.
Thanks,
John
Why don't you use this AdMediator - it is very simple to configure and you don't have to worry about AdMob and iAds (if you want to use it) :
will swap in AdMob ads if no iAds are
available.
Are you releasing bannerView_ in your dealloc method or somewhere else appropriate ?
Instead of:
GADRequest *r = [[GADRequest alloc] init];
You could try:
GADRequest *r = [GADRequest request];

Limit providers while integrating Gigya in iPhone?

I am integrating Gigya in my iphone app. Now it provides 17 providers for access, I want to limit it to just 9 providers. How can I do that?
Has any one integrated it for iPhone? It loads a web view which displays 17 providers in a grouped table format, see here.
To set Facebook and Twitter you can use following code.
GSDictionary *pParams5 = [[GSDictionary new] autorelease];
[pParams5 putStringValue:#"facebook,twitter" forKey:#"enabledProviders"];
[gsAPI showAddConnectionsUI:pParams5 delegate:self context:nil];
GSAPI *gsAPI // declare this
gsAPI = [[GSAPI alloc] initWithAPIKey:<API-KEY> viewController:self]; // i kept this in viewDidload
// add this code to have facebook and twitter on provider list
GSDictionary *pParams5 = [[GSDictionary new] autorelease];
[pParams5 putStringValue:#"facebook,twitter" forKey:#"enabledProviders"];
[gsAPI showAddConnectionsUI:pParams5 delegate:self context:nil];
//this method called when login fails
-(void)gsLoginUIDidFail:(int)errorCode errorMessage:(NSString*)errorMessage context:(id)context{ }
// this method called on successful login
- (void) gsLoginUIDidLogin:(NSString*)provider user:(GSDictionary*)user context:(id)context {}
Check whether you have valid API

iPhone FBConnectDialog box disappears

So I've been trying to integrate FB with my iPhone application with FB connect. However, after using the tutorial (http://www.mobisoftinfotech.com/blog/iphone/iphone-fbconnect-facebook-connect-tutorial/), it seems when the FBDialog box is called, it pops onto the screen for a few seconds and then disappears. I'm not sure what is going, becuase IT WORKS in the Simulator perfectly. I have an iPhone 4 device. Here is my code below:
(void)viewDidLoad {
[super viewDidLoad];
session = [[FBSession sessionForApplication:#"MYAPIKEY" secret:#"MYSECRET" delegate:self] retain];
FBLoginButton *button = [[[FBLoginButton alloc] init] autorelease];
[button setFrame:CGRectMake(100, 100, 100, 50)];
[self.view addSubview:button];
}
Nevermind, I'm sorry for being a noob. Turns out my three hour struggle to figure this out was a complete waste. The problem -- my iPhone wasn't connected to Wifi/cell network.

How to save password in iphone?

I need to create an IPhone Application...Which will communicate with a website...so it requires username and password...Now I need to know how to save the username and password in iphone...I have already used NSuserdefaults...but that didnt solved my pblm....Also I need to restore the view...from where the user exits the application...So I request you to help me?
Regards and thanks for the support,
Syam
I am a bit paranoid about saving secure data (username/passwords) on plain text files such as plist files or NSUserDefaults.
Apple provides Keychain services to store secure data. It is slightly complicated, view the documentation Keychain Services Tasks for iPhone OS
They also provide Generic Keychain app to explore.
You can store the password on a regular file, or you can also store it on a SQLite database.
I had a logout functionality in the app I did recently.
I had a hierarchy as :
"BaseUITableViewController
^
|
"Any subclass of UITAbleView Controller used in project."
all of these subclasses had a "Logout" button and the method to call logout service was written in Base class.
as soon as the response for logout request is valid and the session is killed I call following method (which of your interest in contrast to the above text :))
-(void)gotoMainScreenOnLogout
{
self.navigationController.navigationBarHidden = YES;//to make the previous view invisible
self.navigationController.toolbarHidden=YES; //27 JUNE UPDATE
[self.view removeFromSuperview]; //27 JUNE UPDATE
// MYAPPViewController *homeViewController = [[MYAPPViewController alloc]initWithNibName:#"MYAPPViewController" bundle:nil];
MYAPP_LoginUIVIewController *homeViewController =[[MYAPP_LoginUIVIewController alloc] initWithNibName:#"MYAPP_LoginUIVIewController" bundle:nil];
UINavigationController *nc = [[UINavigationController alloc]initWithRootViewController:homeViewController ];
[nc.navigationBar setBarStyle:UIBarStyleBlackOpaque];
//
UIWindow *MYAPP_window = [[[UIApplication sharedApplication] windows]objectAtIndex:0];
CATransition *transition = [CATransition animation];
transition.duration = 0.8;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionMoveIn;
transition.subtype = kCATransitionFade;
transition.delegate = self;
//...
[MYAPP_window.layer addAnimation:transition forKey:nil];
[MYAPP_window removeAllSubviews]; // not needed anymore
[MYAPP_window addSubview:nc.view];
[homeViewController release];
}
hope this helps.