2017-07-21 67 views
0

我試圖使用Swift 3移動分析,目前有通過CocoaPods AWSCore 2.5.9和AWSMobileAnalytics 2.5.9,但我無法記錄任何事件。我的合作伙伴已使用Android成功記錄了與我使用的CognitoIdentityPoolId相同的事件,並且我還確認它已附加AmazonMobileAnalyticsFullAccess策略。AWS分析 - swift 3 - iOS?

我有內部下面的代碼我的AppDelegate的didFinishLaunchingWithOptions

let credentialsProvider = AWSCognitoCredentialsProvider(regionType:.USWest2, 
        identityPoolId:"us-west-2:theRestOfMyID") 

     let configuration = AWSServiceConfiguration(region:.USWest2, 
                credentialsProvider:credentialsProvider) 

     AWSServiceManager.default().defaultServiceConfiguration = configuration 

     let analyticsConf = AWSMobileAnalyticsConfiguration.init() 

     analyticsConf.serviceConfiguration = AWSServiceManager.default().defaultServiceConfiguration 

     _ = AWSMobileAnalytics.init(forAppId: "MyMobileAnalyticsAppId", configuration: analyticsConf) 

導致的控制檯輸出:

2017-07-20 16:39:53:875 test2[7288:125553] Mobile Analytics SDK(2.0-alpha) Initialization successfully completed. 
2017-07-20 16:39:53:875 test2[7288:125635] 
==========Batch Object========== 
{"attributes":{"_session.id":"82e879d9-C9E6D9C7-20170720-233953870","ver":"v2.0","_session.startTime":"2017-07-20T23:39:53.872Z"},"event_type":"_session.start","timestamp":"2017-07-20T23:39:53.873Z"} 
2017-07-20 16:39:53:876 test2[7288:125635] Event: '_sess...' recorded to local filestore 

我有一個按鈕,我記錄一個事件,然後試圖提交事件:

let eventClient = AWSMobileAnalytics(forAppId: "MyMobileAnalyticsAppId").eventClient 

     guard let client = eventClient else { 
     print("Error creating AMA event client") 
     return 
     } 
     guard let event = client.createEvent(withEventType: "test_50_logIn") else { 
     print("Error creating AMA event") 
     return 
     } 
     event.addAttribute("username", forKey: "sample") 
     event.addAttribute("device", forKey: "ios") 
     client.record(event) 

     client.submitEvents() 

但是,submitEvents總是觸發關注這兩天我一直無法解決的錯誤。因此我一直無法記錄一個iOS事件。

2017-07-20 16:46:01:736 test2[7566:129412] Unable to successfully deliver events to server. Error Message:Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname could not be found." UserInfo={NSUnderlyingError=0x6080002438a0 {Error Domain=kCFErrorDomainCFNetwork Code=-1003 "(null)" UserInfo={_kCFStreamErrorCodeKey=8, _kCFStreamErrorDomainKey=12}}, NSErrorFailingURLStringKey=https://mobileanalytics.us-west-2.amazonaws.com/2014-06-05/events, NSErrorFailingURLKey=https://mobileanalytics.us-west-2.amazonaws.com/2014-06-05/events, _kCFStreamErrorDomainKey=12, _kCFStreamErrorCodeKey=8, NSLocalizedDescription=A server with the specified hostname could not be found.} 

我看到了整合指導下,沒有額外的步驟,沒有人知道這個問題可能是什麼,如果這些ID在Android整合完全正常工作?謝謝!

回答

2

移動分析在美國西部不可用(Docs)。

問:哪些AWS地區是可用的Amazon Mobile Analytics服務?

目前,亞馬遜移動分析可在AWS 美國東部(弗吉尼亞北部)地區。

你只需要改變該地區的AWSServiceConfiguration

let serviceConfiguration = AWSServiceConfiguration(region: .USEast1, credentialsProvider: credentialsProvider) 
let analyticsConfiguration = AWSMobileAnalyticsConfiguration() 
analyticsConfiguration.serviceConfiguration = serviceConfiguration 
_ = AWSMobileAnalytics(forAppId: "MyMobileAnalyticsAppId", configuration: analyticsConfiguration) 

終點:
https://mobileanalytics.us-west-2.amazonaws.com =>不行的
https://mobileanalytics.us-east-1.amazonaws.com/ =>是否

+0

你是現貨,因爲我在android上首先實現了這一點,而在android中你不必處理USEast。我所有的AWS工具都在美國西部,因此分析工作時我使用西部地區,但它沒有工作IOS,這是意外的事情... – TheQ