- fix facebook connection

This commit is contained in:
Giuseppe Nucifora 2016-12-28 19:42:56 +01:00
parent 0c2b3f1c25
commit cc11f1efac
3 changed files with 67 additions and 53 deletions

View File

@ -108,6 +108,7 @@
- (void)applicationDidBecomeActive:(UIApplication *)application
{
[FBSDKAppEvents activateApp];
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
@ -116,6 +117,16 @@
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
return [[FBSDKApplicationDelegate sharedInstance] application:application
openURL:url
sourceApplication:sourceApplication
annotation:annotation];
}
#pragma mark - Remote Notification
- (void) application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {

View File

@ -144,7 +144,16 @@
NSLog(@"response : %@",error);
}];*/
[PNUser socialLoginWithBlockSuccess:^(PNUser * _Nullable responseObject) {
/*[PNUser socialLoginWithBlockSuccess:^(PNUser * _Nullable responseObject) {
} failure:^(NSError * _Nonnull error) {
}];*/
[PNUser socialUserFromViewController:self blockSuccess:^(PNUser * _Nullable responseObject) {
NSLog(@"%@",[[PNUser currentUser] JSONFormObject]);
} failure:^(NSError * _Nonnull error) {

View File

@ -314,27 +314,21 @@ static bool isFirstAccess = YES;
}
}
else {
[[PNObjectConfig sharedInstance] refreshTokenForUserWithFacebookID:[result objectForKey:@"id"] facebookToken:[FBSDKAccessToken currentAccessToken].tokenString withBlockSuccess:^(BOOL refreshSuccess) {
PNUser *user = [[self class] new];
[user setFirstName:[result objectForKey:@"first_name"]];
[user setLastName:[result objectForKey:@"last_name"]];
[user setEmail:[result objectForKey:@"email"]];
[user setFacebookId:[result objectForKey:@"id"]];
[user setAuthenticated:YES];
[user setFacebookUser:YES];
[user saveLocally];
[user reloadFormServer];
USER = user;
if (success) {
success(user);
}
} failure:^(NSError * _Nonnull error) {
if (failure) {
failure(error);
}
}];
}
}];
@ -345,18 +339,18 @@ static bool isFirstAccess = YES;
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
[login logInWithReadPermissions: @[@"public_profile",@"email",@"user_birthday"] fromViewController:viewController handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
if (error) {
NSLog(@"Process error");
NSLogDebug(@"Process error");
if (failure) {
failure(error);
}
} else if (result.isCancelled) {
NSLog(@"Cancelled");
NSLogDebug(@"Cancelled");
if (failure) {
NSError *error = [NSError errorWithDomain:NSLocalizedString(@"Request cancelled", @"") code:kHTTPStatusCodeMethodNotAllowed userInfo:nil];
failure(error);
}
} else {
NSLog(@"Logged in");
NSLogDebug(@"Logged in");
[self socialUserFromViewController:viewController blockSuccess:success failure:failure];
}
}];