facebook login using FBloginView not showing in ios 6 - iphone

i am trying create login button for facebook using FBloginView.
Following is the code i wrote.
- (void)viewDidLoad
{
[super viewDidLoad];
if(!loginview)
loginview = [[FBLoginView alloc] initWithPermissions:[NSArray arrayWithObject:#"publish_actions, user_photos,status_update"]]; // Whatever permissions you need
loginview.frame = self.view.bounds; //whatever you want
loginview.delegate = self;
[self.view addSubview:loginview];
// Do any additional setup after loading the view from its nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)loginViewShowingLoggedInUser:(FBLoginView *)loginView {
NSLog(#"Logged In");
}
- (void)loginViewFetchedUserInfo:(FBLoginView *)loginView
user:(id<FBGraphUser>)user {
NSLog(#"user Id %#",user.id);
}
- (void)loginViewShowingLoggedOutUser:(FBLoginView *)loginView {
// Called after logout
NSLog(#"Logged out");
}
but its not showing login button.
what is the problem with my code. in console am getting "Logged out".

I had FacebookSDKResources.bundle added but still I got the error "Unknown class FBLoginView in interface builder" appearing in the xcode output pane.
To fix this I added the following line to didFinishLaunchingWithOptions :
[FBLoginView class];
This is explained in https://developers.facebook.com/ios/login-ui-control/

As noted by #rajath above, the resolution is to add the FacebookSDKResources.bundle to your project.

Related

Google analytics doesn't show tracking of my App

I would like to Integrate Google Analytics Tracking into my IOS APP.
I have integrated Google Analytics Library and Add It To my Application.
Here is my code snippet,
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[UIApplication sharedApplication].statusBarHidden = NO;
[GAI sharedInstance].trackUncaughtExceptions = YES;
[GAI sharedInstance].dispatchInterval = 1;
[GAI sharedInstance].debug=YES;
[[GAI sharedInstance] trackerWithTrackingId:#"UA-43556575-1"];
return YES;
}
Code In my FirstViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.trackedViewName = #"Home";
....
....
}
List of Librarys which i have added, (First i have copied all this library from download folder then added to my project folder and then in Xcode i am taking reference from project folder)
GAI.h
GAITrackedViewController.h
GAITracker.h
GAITransaction.h
GAITransactionItem.h
libGoogleAnalytics.a
Almost 5 days and still stuck with same problem :(
:
Please Help ...
Thank you for reading and thanks in advance.
I think this may be one case.
Your UIViewController class must be a subclass of the GAITrackedViewController class,
#interface FirstViewController : GAITrackedViewController
And Must override these function.
-(void)viewDidLoad
{
[super viewDidLoad];
self.trackedName = #"Home";
// your code here
}
-(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
// your code here
}
As viewDidLoad and viewDidAppear: are important methods.
And Remember the profile must be for mobile app.

Put FBLoginView in ViewDidLoad crash the app

I have put Facebook loginview code like this
(void)viewDidLoad {
[super viewDidLoad];
// Create Login View so that the app will be granted "status_update" permission.
loginview = [[FBLoginView alloc] init];
loginview.frame = CGRectOffset(loginview.frame, 5, 5);
loginview.delegate = self;
[self.view addSubview:loginview];
[loginview sizeToFit];
}
on first time when i logged in it works fine.But after logged in when i jump to this view from another view it crash the app.
What is the problem?I didn't get it.
I had this same problem. I fixed it by doing this:
-(void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
// This isn't public, so you need to use performSelector...
[fbLoginView performSelector:#selector(unwireViewForSession)];
}
This is based on a bug report here:
https://github.com/buzztabapp/facebook-ios-sdk/commit/2301de144958a5502f9dae0a1bb7c234873581ba
maybe you could try this:
-(void)viewDidLoad
{
...
static id sharedInstance = self;
loginview.delegate = sharedInstance;
...
}
By creating your delegate view instance as static, you store it in the same scope than the facebook login view (which is created in static scope). You avoid bad access error.
I have quit a same problem while dismissing ViewController with FBLoginView.
I solved this problem by setting FBLoginView delegate to nil before calling dismissViewControllerAnimated:completion:
...
self.loginFBView.delegate = nil;
[self dismissViewControllerAnimated:NO completion:nil];

FBLoginView iPhone View

Using the FBLoginView in the current 3.1 Facebook SDK doesn't produce what I believe it should be producing as an output. Generating a basic [[FBLoginView alloc] init]; and the frame the size of the current view controllers frame, it only shows the below WITHOUT the "Login" button:
http://cl.ly/image/1t102j1t452l
What does it take to make the FBLoginView show properly?
Try this:
In .h file:
Use this delegate <FBLoginViewDelegate>
FBLoginView *loginview;
In.m file in someMethod:
if(!loginView)
loginView = [[FBLoginView alloc] initWithPermissions:[NSArray arrayWithObject:#"publish_actions, user_photos,status_update"]]; // Whatever permissions you need
loginview.frame = self.view.bounds; //whatever you want
loginview.delegate = self;
[self.view addSubview:loginview];
Add these methods:
- (void)loginViewShowingLoggedInUser:(FBLoginView *)loginView {
NSLog(#"Logged In");
}
- (void)loginViewFetchedUserInfo:(FBLoginView *)loginView
user:(id<FBGraphUser>)user {
NSLog(#"user Id %#",user.id);
}
- (void)loginViewShowingLoggedOutUser:(FBLoginView *)loginView {
// Called after logout
NSLog(#"Logged out");
}
Hope this helps.
I noticed that I was missing FacebookSDKResources.bundle in my project. When I added it, it started working.

flurry to iphone,add details are not opening

i have integrated flurry to my project and add is displaying successfully.but the problem is when i clicked on the add then its coming like "safari can't open the page",i have used below code,please help me where i went wrong or what will i do?.
-(void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[FlurryAds setAdDelegate:self];
[FlurryAds fetchAndDisplayAdForSpace:#"BANNER_MAIN_VIEW" view:self.view size:BANNER_TOP];
}
-(void) viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
// Reset delegate
[FlurryAds removeAdFromSpace:#"BANNER_MAIN_VIEW"];
}
and in console i am getting like:
webView:shouldStartLoadWithRequest:[http://itunes.apple.com/app/id505821326?partnerId=30&siteID=PIA/JJ6Lt9U]navigationType:5

shouldStartLoadwithRequest not getting called in subclass

I have a view controlled app. On my xib I have no webviews but I do have buttons that bring up classes that have webviews. So hit button one and a uiwebview pops up so on and so forth.
Now in one of my classes I pull up a remote webpage that has a link on it. I want to over-ride that button link with shouldStartLoadwithrequest. How ever this never seems to get called.
Right now my class is called Tenth.m and I have this code in my view controller
- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType {
NSLog(#" Test spot 1");
NSString* scheme = [[request URL] scheme];
if ([#"didTap" isEqual:scheme]) {
// Call your method
NSLog(#" Test spot 2");
[self didTapButton1];
return NO;
} else {
NSLog(#" Test spot 3");
return YES;
}}
But I get nothing (none of my NSLogs). I have tried putting this into my Tenth.m class and still nothing. I have looked at other examples and even downloaded one but it only uses the viewcontroller and delegates classes. No third class.
I'm lost as to why its not getting called.
Here is my third class
#import "Tenth.h"
#implementation Tenth
- (void)awakeFromNib
{
[category10 loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:#"http://www.mywebsite.com/api/didtap.php"]]];
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)dealloc
{
[super dealloc];
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView
{
}
*/
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return YES;
}
#end
remote page code
hello
Tenth.h file
#import <UIKit/UIKit.h>
#interface Tenth : UIViewController <UIWebViewDelegate> {
IBOutlet UIWebView *category10;
}
-(IBAction)back;
#end
My first guess is that the Web view does not have its delegate set. In order for it to call
- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
The class containing this method needs to be set as the webview's delegate. So somewhere in the code there should be a line similar to webView.delegate = <variable>, where the variable is the instance of the class which has implemented the shouldStartLoadWithRequest: method.
This is often "self" when the webView is a subview of a viewController's view. But the way you have described your application, I am not sure if it will be self or not, but it sounds like it will not be self, but the name of the instance of a different class.
Maybe try this:
- (void)viewDidLoad
{
[super viewDidLoad];
// Remember to set web view delegate to self.
category10.delegate = self;
}