我想給Twitter在我的應用程序集成,大多將用於登錄的目的,我想實現它像下面的情況iOS版Twitter的整合
- 檢查是否有已經與手機使用的任何鏈接的Twitter帳戶與反向認證
- 如果沒有帳戶相關聯,使用一些OAuth的庫嘰嘰喳喳,並驗證與
任何人有任何現有的庫/框架做同樣的想法?由於
PS:最低支持IOS版本將是iOS6的
我想給Twitter在我的應用程序集成,大多將用於登錄的目的,我想實現它像下面的情況iOS版Twitter的整合
任何人有任何現有的庫/框架做同樣的想法?由於
PS:最低支持IOS版本將是iOS6的
您可以使用下面的代碼:(如果不考慮從設置中,那麼這將您的應用程序到設備的設置屏幕):
- (IBAction)loginWithTwitterBtn:(id)sender
{
if ([TWTweetComposeViewController canSendTweet])
{
//yes user is logged in
accountStore = [[ACAccountStore alloc] init];
ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
// Request access from the user to use their Twitter accounts.
[accountStore requestAccessToAccountsWithType:accountType withCompletionHandler:^(BOOL granted, NSError *error)
{
// Did user allow us access?
if (granted == YES)
{
// Populate array with all available Twitter accounts
NSArray *arrayOfAccounts = [accountStore accountsWithAccountType:accountType];
ACAccount *acct = [arrayOfAccounts objectAtIndex:0];
// Set the cell text to the username of the twitter account
NSString *userID = [[acct valueForKey:@"properties"] valueForKey:@"user_id"];
}
}];
}
else
{
//show tweeet login prompt to user to login
TWTweetComposeViewController *viewController = [[TWTweetComposeViewController alloc] init];
//hide the tweet screen
viewController.view.hidden = YES;
//fire tweetComposeView to show "No Twitter Accounts" alert view on iOS5.1
viewController.completionHandler = ^(TWTweetComposeViewControllerResult result) {
if (result == TWTweetComposeViewControllerResultCancelled) {
[self dismissModalViewControllerAnimated:NO];
}
};
[self presentModalViewController:viewController animated:NO];
//hide the keyboard
[viewController.view endEditing:YES];
}
}
//*******************
https://github.com/aryansbtloe/LoginViaSocialMedias
這是通過Facebook加入登錄實例項目,嘰嘰喳喳,谷歌,加上和iOS應用程序四層方形的支持。
現在檢查,謝謝btw! – Abhishek
它提供許多不推薦的警告,並且在未配置帳戶時不顯示登錄提示! – Abhishek
Actully我已經在iOS 6中實現了它。當我在答案的頂部添加註釋時,如果它沒有找到任何Twitter帳戶,它會顯示提醒,讓用戶進入設置屏幕.. – Ashutosh