fbDidLogin or fbDidNotLogin not called - facebook

I am trying to integrate facebook login in my existing app. I have the openURL and handleOpenURL methods in AppDelegate.m, but i initialize facebook object in one of the view Controller on click of a button. so my fbDidLogin method is in the viewController, which never gets called. Neither is the fbDidNotLogin is called.
Is it something wrong I am doing?

I had the same problem and it was because i hadnĀ“t set the URL types in the info.plist like it says on the tutorial http://developers.facebook.com/docs/mobile/ios/build/#register

And I have forgotten to implement the only method in the AppDelegate:
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
return [[FacebookService sharedInstance].facebook handleOpenURL:url];
}
FacebookService - is my wrapper singletone class, that contains instance og facebook
the error was the same

Related

Detect app opening?

I have a Tab bar app with 3 view controllers and I use "viewWillAppear" to detect which view is opend.
When I close the app, it still works "in the background" and when I open the app again "viewWillAppear" is not detecting this opening.
Is there any other option to detect this opening? Thanks
You can observe the UIApplicationWillEnterForegroundNotification or implement applicationWillEnterForeground: in your app delegate.
Firstly, You should see the necessary delegation method in UIApplicationDelegate
When you close application that currently open, It will call this method:
- (void)applicationDidEnterBackground:(UIApplication *)application
After the application has been closed but still in dock, you open them again. In the transition state before entering the application, It will call this method:
- (void)applicationWillEnterForeground:(UIApplication *)application
When the application completely presented on previous state before you closed them. It finally call thid method:
- (void)applicationDidBecomeActive:(UIApplication *)application
If you would like to do something in viewWillAppear you should implement in applicationDidBecomeActive to send some message to your current view or other to do what do you want to do after application became actived.
When your app is resumed from the background, it will receive the applicationWillEnterForground: method. It'll get the applicationDidEnterBackground: when it is suspended too.
- (void)applicationWillEnterForeground:(UIApplication *)application {
NSLog(#"app will enter foreground");
[viewController refresh:NULL];
}
i think this will work.
write this in your app delegate

How to properly add "handleOpenURL" method on iPhone App Delegate

I am pretty new to objective-c.
I am working on a Video App. I am trying to connect my App with Facebook.
I am trying to make the "Single Sign On" to work. The flow seems to be working fine:
Facebook App is loaded.
I press "Allow" or "Don't Allow" and my App is being put to foreground.
But, for some reason I cannot make the "handleOpenURL" to work. I followed Facebook instructions and added this method to my class: AVCamViewController (this class is taken from the AVFoundation example App):
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
NSLog(#"Facebook handleOpenURL");
return [facebook handleOpenURL:url];
}
The method is never called.
I guess I am doing something wrong related with the App delegate.
The problem, I don't know exactly what is App delegate and how can I access it?
Can anyone help me to properly use the "handleOpenURL" in my App?
Thanks,
Guy
The handleOpenURL: method is part of the UIApplicationDelegate protocol. You need to implement this method in your application delegate.

applicationWillEnterForeground handleOpenURL problem

I have an app that can be started up by clicking a link from outside the app. Before iOS 4 this worked fine. But now that you have to implement applicationWillEnterForeground, I'm having problems. The problem I have is going from this method to the handleOpenURL method.
I have no problems when didFinishLaunchingWithOptions is called because I handle the url there. But when my app goes into the background, then comes into the foreground, it appears that didFinishLaunchingWithOptions is not being called, or at least not completely. I say not completely because the splash screen comes up and you are taken to the home screen, but this logic only exists inside didFinishLaunchingWithOptions so I'm not sure how the splash page comes up without didFinishLaunchingWithOptions firing. However, the url logic does not fire when the app resumes, and this is also in didFinishLaunchingWithOptions.
I assume this is where I need to use applicationWillEnterForeground, but this method has not options parameter, so how do I get the url and pass it along to
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
All I'm really trying to do is have my app launch from a link after it becomes inactive the way it does when it first launches. I have not implemented applicationWillEnterForeground because I'm not sure what to do with it. All it really needs to do is handle the url.
in case you are still waiting for the answer,
just use the method
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
like you mentioned, this method will automatically be called when your application is called to handle a file ("open in ...")
however, this method is deprecated now, so use this instead
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation

Multitasking and applicationWillEnterForeground

I am trying to have my app reload data when it is brought to the foreground via the applicationWillEnterForeground method. I can get the function to work and write to the NSLog, but I have a function that I want to be called from another class, how would I go about this?
I have tried below:
- (void)applicationWillEnterForeground:(UIApplication *)application {
//Re-run...
[MainViewController reRun];
}
Be gentle bit of a newbie...
You can register to UIApplicationDidBecomeActiveNotification, and reload your data when your receive it.

Discovering if a component is being displayed (of if it's in background), is it possible?

I need to run a method everytime the user switch the screen or return to the application (after a call, or pressing the "Home Button" and returning to the app, for example).
Is there any way to recognize this, like an event or method that is always executed when this happens?
Thank you guys in advance.
Implement those 2 methods in the UIApplicationDelegate :
- (void)applicationDidEnterBackground:(UIApplication *)application
- (void)applicationWillEnterForeground:(UIApplication *)application