SHKFacebook handleDidBecomeActive - no knows class method for selector - ios

I'm trying to get Sharekit Facebook sharing to work. Step 7 in the manual states that these methods should be implemented:
- (void)applicationDidBecomeActive:(UIApplication *)application
{
[SHKFacebook handleDidBecomeActive];
}
- (void)applicationWillTerminate:(UIApplication *)application
{
[SHKFacebook handleWillTerminate];
}
But XCode gives me an error that handleDidBecomeActive and handleWillTerminate are not class methods of SHKFacebook.
Anyidea what I might have done wrong? I linked ShareKit with Cocoapods.

Related

class selector in Facebook login in IOS

I followed the instructions on http://www.appcoda.com/ios-programming-facebook-login-sdk/
It works, but magically
I don't understand this
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[FBLoginView class];
[FBProfilePictureView class];
return YES;
}
What does sending the class message to these classes do? I don't find it in the facebook ios documentation
Calling anything on an NSObject has the side effect to call the lazy initialize method once.
That's how FBLoginView is doing its magic. It would have work with [FBLoginView self]; too.

Xcode re-opening an app

What method is called if I start my app, press the home button and then start the app again/switch to it by doublepressing the home button and selecting it? It is not any of the following as they do not print anything when I re-enter the app:
- (void)applicationWillEnterForeground:(UIApplication *)application {
NSLog(#"Hi");
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
NSLog(#"Hi");
}
- (void)applicationDidFinishLaunching:(UIApplication *)application {
NSLog(#"Hi");
}
No other methods on this site look like they are called when I change to the app, except for trying to add this piece of code but that didn't help;
- (BOOL)application:(UIApplication *)application shouldRestoreApplicationState:(NSCoder *)coder {
return false;
}
It feels like an extremely easy task but I've been testing all possible methods for 3 hours now. What method is called when I re-enter my application after opening it?
Edit: This has been resolved now, if anyone else is having problems of the same sort this image is super helpful. I found it after resolving my issue: http://www.cocoanetics.com/files/Bildschirmfoto-2012-03-05-um-5.26.29-PM.png
Firstly,
- (void)applicationWillEnterForeground:(UIApplication *)application
method will be called, and after that
- (void)applicationDidBecomeActive:(UIApplication *)application
method will be called after you open the application from the background thread.

FBLoginView delegate methods not called anymore

I am using the FBLoginView (version 3.xx) in my app to automatically create useraccounts based on their Facebook profile, but the delegate callbacks of FBLoginViewDelegate don't get called anymore.
My code is as folloows:
In the didFinishLaunchingWithOptions method of my AppDelegate I have this line:
[FBLoginView class];
I have a class called LoginHandler that conformes to the FBLoginViewDelegate protocol and which implements these methods:
- (void)loginViewShowingLoggedInUser:(FBLoginView *)loginView
- (void)loginViewShowingLoggedOutUser:(FBLoginView *)loginView
- (void)loginViewFetchedUserInfo:(FBLoginView *)loginView user:(id<FBGraphUser>)user
- (void)loginView:(FBLoginView *)loginView handleError:(NSError *)error
In the viewDidLoad method of my view controller I have this code:
self.fbLoginView.readPermissions = #[#"public_profile", #"email"];
self.fbLoginView.delegate = [LoginHandler sharedInstance];
I also have set up my Info.plist with:
FacebookAppID (containing <my-app-id>)
FacebookDisplayName (containing my app name=
CFBundleURLSchemes (containing fb<my-app-id>)
When I press the Facebook login button it switches over to the Facebook app, asks about the permisions (only the first time) and returns to my app. However, none of the delegate methods get called at this point. This used to work before and I did get callbacks for both loginViewShowingLoggedInUser and loginViewFetchedUserInfo, but some time ago it stopped working and I simply can't figure out what changes have broken it.
An interesting thing is that every time I start the app (before I do anything with the Facebook button) my loginViewShowingLoggedOutUser gets called. I don't know if it is related to my issue or if this is normal behaviour.
I have found the answer. I needed to override this method in my app delegate.
-(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
// Call FBAppCall's handleOpenURL:sourceApplication to handle Facebook app responses
BOOL wasHandled = [FBAppCall handleOpenURL:url sourceApplication:sourceApplication];
// You can add your app-specific url handling code here if needed
return wasHandled;
}

iOS - Facebook single sign on - from my view controller

In the documentation from facebook to integrate their sdk in iOS app, they mentioned everything in app delegate. But in my application, i've settings view which has option for "Facebook". When user clicks that then only i want to enable single sign on from my application. This can be done by creating facebook object etc in my settings view controller. But in app delegate, they are asking to ad the following code:
// Pre 4.2 support
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
return [facebook handleOpenURL:url];
}
// For 4.2+ support
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
return [facebook handleOpenURL:url];
}
And both the above methods has to be implemented in app delegate class with "facebook" as object. But I'm creating my facebook object in my settings view controller. How should I handle this situation?
Add this to your AppDelegate.m (and add it to the .h header file)
+ (AppDelegate*) sharedAppDelegate {
return (AppDelegate*) [UIApplication sharedApplication].delegate;
}
Include the header file and do this to access your facebook object from any view controller:
[[AppDelegate sharedAppDelegate] facebook]
as mentioned in the docs, I'm creating the facebook object and calling the methods in app delegate from the settings view

Implementing SSO return a Blank view

I'm trying to implement SSO following the Tutorial:
https://developers.facebook.com/docs/mobile/ios/build/
At the end of Step 3, I'm supposed to Test my App running it on Simulator. The Run succeeded but all I see is a Blank View (screen). I'm not sure if I need to create the view called "authorization dialog" including the FB logo, buttons, etc or if it's automatically created by code I've implemented using Facebook SDK.
Also, I'm using a storyboard and wonder if that's the problem.
I think that it's because you have once signed in and now you haven't logged out so it is already authorized and hence you cannot see anything :)
Is your initial ViewController blankView ? Because the SSO only validates/autorize the session, you need to implement the UI in your ViewController.
If you implement it in Storyboard I suggest you to do most of the code in your controller file, since I was stucked there for quite long time. But make sure to put this code in the app delegate file.
#pragma mark Facebook
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
return [self.facebook handleOpenURL:url];
}
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication: (NSString *)sourceApplication annotation:(id)annotation {
return [self.facebook handleOpenURL:url];
}
Also in the delegate file you should instantiate the Facebook object before you use the in the above methods.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
viewController *controller = [[viewController alloc] init];
// Initialize Facebook
facebook = [[Facebook alloc] initWithAppId:#"Your app ID in string" andDelegate:controller];
// Override point for customization after application launch.
return YES;
}

Resources