我的应用程序允许典型注册(电子邮件,用户名,密码等),但也可以通过Parse启用Facebook / Twitter注册/唱歌。如果可能的话,我想避免强迫用户在Facebook或Twitter登录时两次登录。目前,我添加了“Scringo”的程序化注册功能,使用与我的应用程序相同的凭据将用户签入“scringo”;然而。如果他们与Facebook注册怎么办?对于用户来说,使用Facebook登录,然后滑动条形图并且访问消息传递组件以强制再次使用Facebook登录,这似乎非常令人困惑。
这就是我目前所拥有的,无论如何都要链接Facebook / Twitter登录过程,以便Parse只需按一个按钮即可获得Scringo的信息吗?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[Parse setApplicationId:@"...gzPI7Omoxc..."
clientKey:@"...s22ZqIbM7n..."];
[PFTwitterUtils
initializeWithConsumerKey:@"...W4XjjpHz..."
consumerSecret:@"...Czjtht7v5..."];
[PFAnalytics trackAppOpenedWithLaunchOptions:launchOptions];
[PFFacebookUtils initializeFacebook];
[self configureNavigationBar];
[Scringo initWithAppId:@"...N2cCMhW1Bv..." completion:^{
[Scringo addSidebar:self.window toLeft:YES];
PFUser *currentUser = [PFUser currentUser];
if (! [ScringoUser currentUser].isAuthenticated) {
[ScringoUser signUpWithEmail:currentUser.email userName:currentUser.username password:@"notforyou" completion:^(ScringoUser *aUser, BOOL isSuccess) {
if (isSuccess) {
[currentUser setObject:aUser.userId forKey:@"ScringoUserId"];
[currentUser saveInBackground];
}
}];
}
}];
return YES;
}
答案 0 :(得分:0)
原来SDK中有一个方法(我只是忽略了它)
[Scringo connectFacebook]
如果该应用已成功登录facebook,则也可以通过调用此方式验证Scringo。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[Parse setApplicationId:@"gzPI7OmoxcSYqQGWASjzVd8lP5q8FVJqh2ZLsXnp"
clientKey:@"s22ZqIbM7n8SN1End57vmTmmeL55YnIen7dmMhIR"];
[PFTwitterUtils
initializeWithConsumerKey:@"W4XjjpHzG03bWK8R0iPvs27Yy"
consumerSecret:@"Czjtht7v58yfZ00QV5Gkumfdy8RauCyPllYh5SPm00I3M6fkPP"];
[PFAnalytics trackAppOpenedWithLaunchOptions:launchOptions];
[PFFacebookUtils initializeFacebook];
[self configureNavigationBar];
[Scringo initWithAppId:@"cvOV3lLwQN2cCMhW1BvnW2eWnyoiLNgA" completion:^{
[Scringo addSidebar:self.window toLeft:YES];
PFUser *currentUser = [PFUser currentUser];
if (! [ScringoUser currentUser].isAuthenticated) {
if (currentUser) {
if (currentUser.email) [Scringo connectFacebook];
else
[ScringoUser signUpWithEmail:currentUser.email userName:currentUser.username password:@"notforyou" completion:^(ScringoUser *aUser, BOOL isSuccess) {
if (isSuccess) {
[currentUser setObject:aUser.userId forKey:@"ScringoUserId"];
[currentUser saveInBackground];
}
}];
}
}
}];
return YES;
}
假设PFUser已经存在,所以我也为登录用户首次登录的用户添加了相同的呼叫
- (void)logInViewController:(PFLogInViewController *)logInController didLogInUser:(PFUser *)user {
[self dismissViewControllerAnimated:YES completion:^{
if (!self.currentUser.email) [Scringo connectFacebook];
}];
}
经过测试和工作。