I've been trying to develop iOS app using Facebook and I'm new. So I've been trying to make
a login with Facebook, followed a tutorial on Facebook and try to implement it.
But I've encountered, [FBSession sessionOpenWithPermissions]
not found. When I run the
app, it will force close and say that error. When build the project, it will show warning
yellow exclamation that sessionOpenWithPermission
is not found in FBSession
The tutorial outdated? If it is, then what is the new code for the new Facebook SDK for
sessionOpenWithPermission ?
To implement this new version of Facebook Login, Developers should update their Facebook iOS SDK or Facebook SDK for Unity to version 9.0+. Today, we will launch Facebook Platform SDK version 9.0 and begin the deprecation of all prior SDK versions.
The deprecation will happen over a two year period (ending on January 19th, 2023) at the end of which all previous versions of the Facebook Platform SDK will be permanently sunset. At that point, no responses will be generated for any API calls made to previous versions (v8.2 and below) of the Facebook Platform SDK.
Add the type definitions from @types/facebook-js-sdk with the following npm command: 2. Then add "facebook-js-sdk" to the "types" array in your tsconfig.app.json file:
Facebook Login now offers a Limited Login mode. When using the limited version of Facebook Login, the fact that a person used Facebook Login with this iOS app will not be used to personalize or measure advertising effectiveness.
Try This Code
account = [[ACAccountStore alloc] init];
accountType = [account accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
arrayOfAccounts = [account accountsWithAccountType:accountType];
appDelegate= (AppDelegate *)[[UIApplication sharedApplication] delegate];
chk=appDelegate.chk_login;
if (!appDelegate.session.isOpen) {
// create a fresh session object
appDelegate.session = [[FBSession alloc] init];
if (appDelegate.session.state == FBSessionStateCreatedTokenLoaded) {
// even though we had a cached token, we need to login to make the session usable
[appDelegate.session openWithCompletionHandler:^(FBSession *session,
FBSessionState status,
NSError *error) {
// we recurse here, in order to update buttons and labels
}];
}
}
Maybe this code helps you, put it in your AppDelegate.m
class
- (void)sessionStateChanged:(FBSession *)session
state:(FBSessionState) state
error:(NSError *)error
{
switch (state) {
case FBSessionStateOpen: {
self.loggedinVCController = [[LoggedinVC alloc] initWithNibName:@"LoggedinVC" bundle:nil];
self.navController = [[UINavigationController alloc]initWithRootViewController:self.loggedinVCController];
self.window.rootViewControlle`enter code here`r = self.navController;
}
break;
case FBSessionStateClosed:
case FBSessionStateClosedLoginFailed:
// Once the user has logged in, we want them to
// be looking at the root view.
[self.navController popToRootViewControllerAnimated:NO];
[FBSession.activeSession closeAndClearTokenInformation];
self.viewController = [[SampleViewController alloc] initWithNibName:@"SampleViewController" bundle:nil];
self.window.rootViewController = self.viewController;
break;
default:
break;
}
if (error) {
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:@"Error"
message:error.localizedDescription
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
}
}
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation
{
return [FBSession.activeSession handleOpenURL:url];
}
- (void)openSession
{
[FBSession openActiveSessionWithReadPermissions:nil
allowLoginUI:YES
completionHandler:
^(FBSession *session,
FBSessionState state, NSError *error) {
[self sessionStateChanged:session state:state error:error];
}];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With