我閱讀Facebook文檔並找到一些登錄Facebook的方法。如何登錄與嵌入式網頁視圖登錄對話框與FB SDK 3.5.x的在嵌入式WebView登錄對話框中登錄facebook應用
0
A
回答
0
這可能是有用的,以你和Facebook的一些委託方法也顯示下方
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
return [facebook handleOpenURL:url];
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
// Although the SDK attempts to refresh its access tokens when it makes API calls,
// it's a good practice to refresh the access token also when the app becomes active.
// This gives apps that seldom make api calls a higher chance of having a non expired
// access token.
[[self facebook] extendAccessTokenIfNeeded];
}
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
NSLog(@"url->%@",url);
return [self.facebook handleOpenURL:url];
}
- (BOOL)isFBLoggedIn
{
return [facebook isSessionValid];
}
- (void)login
{
if (![facebook isSessionValid])
{
[facebook authorize:[[NSArray alloc] initWithObjects:@"offline_access", nil]];
} else
{
[facebook logout];
[facebook authorize:[[NSArray alloc] initWithObjects:@"offline_access", nil]];
}
}
- (void)fetchFBFriends
{
[facebook requestWithGraphPath:@"me/friends" andDelegate:self];
}
-(void)fetchFbDetails
{
[facebook requestWithGraphPath:@"me" andDelegate:self];
}
- (void)storeAuthData:(NSString *)accessToken expiresAt:(NSDate *)expiresAt
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:accessToken forKey:@"FBAccessTokenKey"];
[defaults setObject:expiresAt forKey:@"FBExpirationDateKey"];
[defaults synchronize];
}
NSString *strRes = [NSString stringWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://graph.facebook.com/me?fields=name,username,email,gender,birthday,hometown,picture&access_token=%@",facebook.accessToken]] usedEncoding:&encoding error:&error];
NSMutableDictionary *dirFbDetails = [[NSMutableDictionary alloc] initWithDictionary:[strRes JSONValue]];
-(void)fbDidExtendToken:(NSString *)accessToken expiresAt:(NSDate *)expiresAt
{
NSLog(@"token extended");
[self storeAuthData:accessToken expiresAt:expiresAt];
}
-(void)doFaceBookLogin
{
[self.facebook authorize:[NSArray arrayWithObjects:@"friends_birthday",@"user_birthday",@"email",@"publish_stream",nil]];
}
#pragma mark - FBRequestDelegate Methods
- (void)request:(FBRequest *)request didReceiveResponse:(NSURLResponse *)response
{
}
- (void)request:(FBRequest *)request didLoad:(id)result
{
}
- (void)request:(FBRequest *)request didFailWithError:(NSError *)error
{
NSLog(@"Err message: %@", [[error userInfo] objectForKey:@"error_msg"]);
NSLog(@"Err code: %d", [error code]);
}
相關問題
- 1. Facebook登錄對話框中
- 2. Facebook Connect登錄對話框
- 3. Facebook的登錄不不解僱登錄對話框登錄後
- 4. 如何禁用Facebook登錄對話框
- 5. 對話框中的Facebook登錄按鈕
- 6. Android Webview Facebook登錄
- 7. Facebook登錄android WebView
- 8. Webview與對話框中的Facebook登錄閃爍
- 9. Facebook登錄不會打開登錄對話框objective-c
- 10. Facebook賬戶登錄在webview
- 11. 的Facebook SDK登錄對話框兩次
- 12. 解析Facebook登錄 - Javascript對話框
- 13. Facebook的Android SDK登錄對話框
- 14. Android - > Facebook登錄沒有對話框?
- 15. 如何在Facebook登錄對話框中以其他用戶身份登錄
- 16. facebook對話ios登錄
- 17. 在iPhone登錄後在WebView中再次登錄Facebook我
- 18. 登錄對話框循環警報對於Facebook應用程序
- 19. 應用程序與Facebook登錄登錄
- 20. Android的Facebook登錄與webview
- 21. Android的webview,與facebook登錄
- 22. Facebook Sdk崩潰Webview登錄
- 23. Android WebView與Facebook登錄
- 24. 如何在用戶登錄時刪除登錄對話框?
- 25. Facebook應用登錄
- 26. Qt - 登錄對話框
- 27. 登錄對話框PyQt
- 28. 棱鏡登錄對話框
- 29. Facebook登錄響應對象
- 30. Facebook連接登錄對話框崩潰應用程序
[Rü問任何問題?或提供解決方案如何使用Facebook。 – Romance
我的意思是如何使用嵌入式webview在我的應用中登錄Facebook,而不是使用Safari或Facebook原生應用。 – John
請檢查下面的代碼 – Romance