2015-05-31 106 views
1

我收到这个错误的坚果。请有一个确切的看看错误信息!它是“SS ErrorDomain”NOT“SK ...”结合代码= 0。到目前为止,我无法在网络上的任何地方找到任何同样的问题。人们似乎有SS ErrorDomain代码= 或SK ErrorDomain代码= 。到目前为止,我的组合没有描述,也没有任何帮助。错误域= SSErrorDomain代码= 0“无法连接到iTunes Store”

好的,这是我的尝试:应用程序工作正常,没有在应用程序自1月1日以来,它是在商店可用。现在我已经添加了应用内购买到我的应用程序。我尝试测试它们,但我得到的只是上面的错误。它甚至不会试图问我一个测试用户或任何东西。

我绝对相信,我退出了商店,在一个真正的设备上工作,并做了所有其他测试(很多次),我可以在网上找到。没有!仍然“无法连接...”

我已检查此处描述的所有内容Ray Wenderlichs In-App Tutorial。我甚至用他的教程从头创建了一个新的应用程序。同样的问题。等了几天也没有帮助。

我已经完成了这里描述的东西Cannot connect to iTunes in Baker Factory。你可以猜出结果。

这是一些代码。只要这就是所谓的viewDidLoad()开始:

internal class InApp : NSObject, SKProductsRequestDelegate, SKPaymentTransactionObserver { 
private var request: SKProductsRequest! 

// Start communication with Apple Store to retrieve list of available products 
internal func start() { 
    if let url = NSBundle.mainBundle().URLForResource("InAppProducts", withExtension: "plist") { 
     if let productIds = NSArray(contentsOfURL: url) { 
      NSLog("InApp: Product-Id \(productIds)") 
      SKPaymentQueue.defaultQueue().addTransactionObserver(self) 
      request = SKProductsRequest(productIdentifiers: Set(arrayLiteral: productIds)) 
      request.delegate = self 
      request.start() 
      NSLog("InApp: request started") 
     } 
    } 
} 

日志打印出两款产品的ID,从plist中读取正确。日志还显示“请求已启动”。之后,它直接调用错误例程:

internal func request(request: SKRequest!, didFailWithError error: NSError!) { 
    NSLog("ERROR: decription: \(error!.description), reason: \(error!.localizedFailureReason), options: \(error!.localizedRecoveryOptions), suggestion: \(error!.localizedRecoverySuggestion)") 
} 

我正在使用Xcode 6.3和iOS 6的iOS 6。 GameCenter iAdBanner和所有其他功能完美工作。

任何任何建议,我可以看看,我能做什么,是高度欢迎!

回答

3

最后我找到了。它实际上是这一个的重复:Swift Cannot connect to iTunes

下面的代码片段我已经改变了: OLD/WRONG:

  if let url = NSBundle.mainBundle().URLForResource("InAppProducts", withExtension: "plist") { 
      if let productIds = NSArray(contentsOfURL: url) { 
       let request = SKProductsRequest(productIdentifiers: Set(arrayLiteral: productIds)) 
       request.delegate = self 
       request.start() 
       return true 
      } 
     } 

NEW/RIGHT:

  if let url = NSBundle.mainBundle().URLForResource("InAppProducts", withExtension: "plist") { 
      if let productIds = NSArray(contentsOfURL: url) { 
       var set = Set<String>() 
       for productId in productIds { 
        if let productId = productId as? String {set.insert(productId as String)} 
       } 
       log("InApp: Product-Id \(productIds) = \(set))") 

       let request = SKProductsRequest(productIdentifiers: set) 
       request.delegate = self 
       request.start() 
       return true 
      } 
     } 

基本上,我从plist中阅读,因为它犯了一个错误作为一个对象存储在一个集合中,包含两个字符串。现在它真的是一套两个字符串。

最后,一个非常“有趣”的错误消息根本无法启动请求!

相关问题