- fix facebook connection
This commit is contained in:
parent
0c2b3f1c25
commit
cc11f1efac
@ -108,6 +108,7 @@
|
|||||||
|
|
||||||
- (void)applicationDidBecomeActive:(UIApplication *)application
|
- (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.
|
// 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:.
|
// 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
|
#pragma mark - Remote Notification
|
||||||
|
|
||||||
- (void) application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
|
- (void) application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
|
||||||
|
|||||||
@ -144,7 +144,16 @@
|
|||||||
NSLog(@"response : %@",error);
|
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) {
|
} failure:^(NSError * _Nonnull error) {
|
||||||
|
|
||||||
|
|||||||
@ -314,27 +314,21 @@ static bool isFirstAccess = YES;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
[[PNObjectConfig sharedInstance] refreshTokenForUserWithFacebookID:[result objectForKey:@"id"] facebookToken:[FBSDKAccessToken currentAccessToken].tokenString withBlockSuccess:^(BOOL refreshSuccess) {
|
|
||||||
|
|
||||||
PNUser *user = [[self class] new];
|
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 setFacebookId:[result objectForKey:@"id"]];
|
||||||
[user setAuthenticated:YES];
|
[user setAuthenticated:YES];
|
||||||
[user setFacebookUser:YES];
|
[user setFacebookUser:YES];
|
||||||
[user saveLocally];
|
[user saveLocally];
|
||||||
[user reloadFormServer];
|
|
||||||
|
|
||||||
USER = user;
|
USER = user;
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
success(user);
|
success(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
} failure:^(NSError * _Nonnull error) {
|
|
||||||
if (failure) {
|
|
||||||
failure(error);
|
|
||||||
}
|
|
||||||
}];
|
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
|
||||||
@ -345,18 +339,18 @@ static bool isFirstAccess = YES;
|
|||||||
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
|
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
|
||||||
[login logInWithReadPermissions: @[@"public_profile",@"email",@"user_birthday"] fromViewController:viewController handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
|
[login logInWithReadPermissions: @[@"public_profile",@"email",@"user_birthday"] fromViewController:viewController handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
|
||||||
if (error) {
|
if (error) {
|
||||||
NSLog(@"Process error");
|
NSLogDebug(@"Process error");
|
||||||
if (failure) {
|
if (failure) {
|
||||||
failure(error);
|
failure(error);
|
||||||
}
|
}
|
||||||
} else if (result.isCancelled) {
|
} else if (result.isCancelled) {
|
||||||
NSLog(@"Cancelled");
|
NSLogDebug(@"Cancelled");
|
||||||
if (failure) {
|
if (failure) {
|
||||||
NSError *error = [NSError errorWithDomain:NSLocalizedString(@"Request cancelled", @"") code:kHTTPStatusCodeMethodNotAllowed userInfo:nil];
|
NSError *error = [NSError errorWithDomain:NSLocalizedString(@"Request cancelled", @"") code:kHTTPStatusCodeMethodNotAllowed userInfo:nil];
|
||||||
failure(error);
|
failure(error);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
NSLog(@"Logged in");
|
NSLogDebug(@"Logged in");
|
||||||
[self socialUserFromViewController:viewController blockSuccess:success failure:failure];
|
[self socialUserFromViewController:viewController blockSuccess:success failure:failure];
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user