我正在研究一個ios應用程序,最近我有一個新的要求,即爲用戶提供一個選項,使用Gmail登錄。當用戶點擊登錄按鈕,然後我想要打開Gmail登錄屏幕,並在用戶輸入他的憑據後,如果憑證是正確的,那麼不是打開他的郵件,我希望控件導航到我的應用程序主頁。誰能告訴我如何實現這個在ios應用程序中的gmail集成
回答
最後我找到了解決方案。 。 .i認爲這將幫助其他人 按照以下步驟將gmail與您的應用程序集成。
1.爲您的項目添加以下類。
GTMHTTPFetcher.h,GTMHTTPFetcher.m,GTMOAuth2Authentication.h,GTMOAuth2Authentication.m,GTMOAuth2SignIn.h,GTMOAuth2SignIn.m,GTMOAuth2ViewControllerTouch.h,GTMOAuth2ViewControllerTouch.m,GTMOAuth2ViewTouch.xib,SBJSON.h,SBJSON.m
,你會在這裏得到這些類:https://github.com/jonmountjoy/Force.com-iOS-oAuth-2.0-Example
注意:如果您在ARC環境下工作,那麼你必須禁用ARC了以下文件:
GTMHTTPFetcher.m,GTMOAuth2Authentication.m,GTMOAuth2SignIn.m, GTMOAuth2ViewController Touch.m
要在Xcode 4中禁用源文件的ARC,請在Xcode中選擇項目和目標。在目標「構建階段」選項卡下,展開編譯源構建階段,選擇庫源文件,然後按Enter打開編輯字段,然後鍵入-fno-objc-arc作爲這些文件的編譯器標誌。
2.添加以下框架
security.framework , systemConfiguration.framework
3.註冊應用程式,以前往Google API控制檯...。這裏:https://code.google.com/apis/console
然後轉到ApiAccess部分,爲iOS應用創建客戶端ID。 那麼你將得到clientID,ClientSecret和RedirectUrl
* 4.現在是編碼的時候了。 。 。 。 *
在您的控制器中創建一個登錄按鈕併爲其設置操作。這裏當用戶點擊按鈕SignInGoogleButtonClicked方法被調用。
//import GTMOAuth2Authentication , GTMOAuth2ViewControllerTouch
#define GoogleClientID @"paster your client id"
#define GoogleClientSecret @"paste your client secret"
#define GoogleAuthURL @"https://accounts.google.com/o/oauth2/auth"
#define GoogleTokenURL @"https://accounts.google.com/o/oauth2/token"
-(void) SignInGoogleButtonClicked
{
NSURL * tokenURL = [NSURL URLWithString:GoogleTokenURL];
NSString * redirectURI = @"urn:ietf:wg:oauth:2.0:oob";
GTMOAuth2Authentication * auth;
auth = [GTMOAuth2Authentication authenticationWithServiceProvider:@"google"
tokenURL:tokenURL
redirectURI:redirectURI
clientID:GoogleClientID
clientSecret:GoogleClientSecret];
auth.scope = @"https://www.googleapis.com/auth/plus.me";
GTMOAuth2ViewControllerTouch * viewcontroller = [[GTMOAuth2ViewControllerTouch alloc] initWithAuthentication:auth
authorizationURL:[NSURL URLWithString:GoogleAuthURL]
keychainItemName:@"GoogleKeychainName" delegate:self
finishedSelector:@selector(viewController:finishedWithAuth:error:)];
[self.navigationController pushViewController:viewcontroller animated:YES];
}
//this method is called when authentication finished
- (void)viewController:(GTMOAuth2ViewControllerTouch *)viewController finishedWithAuth:(GTMOAuth2Authentication *)auth error:(NSError *)error
{
if (error != nil) {
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Error Authorizing with Google"
message:[error localizedDescription]
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
else
{
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Alert !"
message:@"success"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
}
我發現了。但後來我只是能夠獲取片段,即電子郵件正文&的前幾個字不是整個。我剛剛停止因爲我沒有找到任何其他方式來這樣做。因爲我使用OAuth 2.0。
- 1. 將gmail與ios應用程序集成
- 2. 在ios應用程序中集成googleDrive
- 3. XlsLib在IOS應用程序中集成
- 4. 在我的應用程序中需要Gmail集成幫助
- 5. Gmail集成在iOS中的示例
- 6. 在asp.net web應用程序中集成gmail
- 7. IOS應用程序與facebook的集成
- 8. ios應用程序的Twitter集成
- 9. iOS應用程序與硬件集成
- 10. Youtube與iOS應用程序集成。
- 11. iOS設置應用程序集成
- 12. iOS集成照片應用程序
- 13. Ios應用程序和TestFlight集成
- 14. WebRTC與iOS應用程序集成
- 15. Docusign與Android/Ios應用程序集成
- 16. OpenFeint與iOS應用程序集成
- 17. AEM- IOS應用程序集成
- 18. 微博集成在iOS 6和Google集成在iOS 6應用程序
- 19. Facebook,Twitter和Gmail在Android應用程序集成
- 20. 在iOS中集成一個應用程序與其他應用程序
- 21. 在我的IOS應用程序中集成Tumblr API
- 22. 在我的iOS應用程序中集成jquery-javascript項目
- 23. 有沒有集成Gmail和Basecamp的應用程序?
- 24. 在iOS應用程序中使用monogame集成Admob
- 25. iOS應用程序Facebook集成 - iOS 5.0的備用
- 26. 支持Gmail應用程序中的響應電子郵件應用程序IOS
- 27. 在Android應用程序中的Flash應用程序集成
- 28. 如何在我的應用程序中集成gmail的登錄系統?
- 29. 在iOS應用程序中針對Gmail的推送通知
- 30. 在ios應用程序中集成vimeo視頻
嘿RU能夠將Gmail集成到你的應用程序。請給我一個GUD鏈接。我試過你的答案,但我得到錯誤錯誤域= com.google.GTMOAuth2代碼= -1001 ..當我去一個不同的代碼之後此鏈接http://technogerms.com/login-with-google-using-oauth-2-0-for-ios-xcode-objective-c/我獲取訪問令牌,但無法使用該訪問令牌檢索用戶詳細信息 – Honey
@arizah,什麼是你的電子郵件ID,我可以發送UA樣本 –
好吧,請將它發送到簡歷中的ID – Honey