jeudi 26 mars 2015

Does Facebook SDK distinguish between iOS debug vs release build

Does Facebook distinguish between debug and release iOS builds? I am testing my app before submitting a new build to iTunes. My app uses the single permission of posting photo on Facebook (i.e. publish_actions). The strange thing is when I test with my Facebook account, it goes through fine. But when I test with my partner's Facebook account, it does not go through: The developer account is linked to my Facebook account; not my partner's. Basically for the following method



// Convenience method to perform some action that requires the "publish_actions" permissions.
- (void)performPublishAction:(void(^)(void))action {
// we defer request for permission to post to the moment of post, then we check for the permission
if ([FBSession.activeSession.permissions indexOfObject:@"publish_actions"] == NSNotFound) {
// if we don't already have the permission, then we request it now
NSLog(@"Requesting publish permission");
[FBSession.activeSession requestNewPublishPermissions:@[@"publish_actions"]
defaultAudience:FBSessionDefaultAudienceFriends
completionHandler:^(FBSession *session, NSError *error) {
NSLog(@"Completion handler returns for permission");
NSLog(@"My Permissions are: %@",session.permissions);
if (!error) {
NSLog(@"Okay no error");
action();
} else if (error.fberrorCategory != FBErrorCategoryUserCancelled) { NSLog(@"ERROR GETTING PERMISSION:: %@",error);
}
}];
} else {
NSLog(@"the other route");
action();
}

}


action() is never called.


The line



NSLog(@"My Permissions are: %@",session.permissions);


prints



My Permissions are: (
"public_profile"
)


And the line



NSLog(@"The ERROR IS: %@",error);


prints



The ERROR IS: Error Domain=com.facebook.sdk Code=2
"The operation couldn’t be completed. com.facebook.sdk:ErrorReauthorizeFailedReasonUserCancelled" UserInfo=0x1702779c0
{com.facebook.sdk:ErrorLoginFailedReason=com.facebook.sdk:ErrorReauthorizeFailedReasonUserCancelled,
NSLocalizedFailureReason=com.facebook.sdk:ErrorReauthorizeFailedReasonUserCancelled,
com.facebook.sdk:ErrorSessionKey=<FBSession: 0x170169480, state: FBSessionStateOpen, loginHandler:
0x100374240, appID: 123456789, urlSchemeSuffix: ,
tokenCachingStrategy:<FBSessionTokenCachingStrategy: 0x17022a740>, expirationDate: 2015-05-19 19:07:02 +0000,
refreshDate: 2015-03-20 19:07:02 +0000, attemptedRefreshDate: 0000-12-30 00:00:00 +0000, permissions:(
"public_profile"
)>}



Aucun commentaire:

Enregistrer un commentaire