【问题标题】:WeatherKit⛈ iOS SDK 401 network error WWDC 2022WeatherKit⛈ iOS SDK 401 网络错误 WWDC 2022
【发布时间】:2022-08-17 03:36:56
【问题描述】:

嘿开发者?????????‍???????????????????,

运行 WWDC22 Link 时出现错误

我从here 下载了 Apple 的示例项目

而且我能够运行该项目。但是当我创建一个演示项目并添加天气获取代码时,我得到了错误。

我的代码:

func fetchWeather() async {
       let service = WeatherService.shared
        var location: CLLocation = CLLocation(latitude: 22.7196, longitude: 75.8577)
        
        let weatherData = try? await service.weather(for: location, including: .current)
        print(weatherData)
    }

错误:

2022-06-22 17:31:48.470130+0530 WeatherAPIDemo[25490:231389] [Database] Attempting to invalidate an assertion that is no longer valid 2022-06-22 17:31:49.208346+0530 WeatherAPIDemo[25490:231387] [WeatherService] Encountered an error when fetching weather data subset; location=<+22.71960000,+75.85770000> +/- 0.00m (speed -1.00 mps / course -1.00) @ 6/22/22, 5:31:48 PM India Standard Time,  error=invalidJWTResponse(Optional(<NSHTTPURLResponse: 0x60000308c420> { URL: https://weather-data.apple.com/v2/token } { Status Code: 401, Headers {
Connection =     (
    close
);
\"Content-Length\" =     (
    0
);
Date =     (
    \"Wed, 22 Jun 2022 12:01:49 GMT\"
);
Server =     (
    Apple
);
\"Strict-Transport-Security\" =     (
    \"max-age=31536000; includeSubdomains\"
);
\"X-Apple-Origin\" =     (
    \"8961098f-b238-3714-ba44-5b569c861456\"
);
\"X-Cache\" =     (
    \"TCP_MISS from a49-44-192-207.deploy.akamaitechnologies.com (AkamaiGHost/10.8.2-41841244) (-)\"
);
\"X-Content-Type-Options\" =     (
    nosniff
);
\"X-Frame-Options\" =     (
    SAMEORIGIN
);
\"X-REQUEST-ID\" =     (
    \"8c733cde-5aa3-499c-b555-05c5aab5e278\"
);
\"X-XSS-Protection\" =     (
    \"1; mode=block\"
);

} })) 零

  • 您是否拥有 Apple Developer Program 的会员资格?因为您需要将 WeatherKit 添加到您的配置文件中。
  • 状态码:401,表示未经授权。您可能需要为此获得一些授权。

标签: swift weather wwdc


【解决方案1】:

即使我添加了我也尝试了很多天气套件在能力中但没有奏效。

我认为问题一定是我没有开发者帐户但后来我意识到即使没有添加任何团队,Apple Demo Project 也可以正常工作(Apple Demo Project 参见下面的 img)。

然后我只是在我的演示项目和 Boom 中复制并粘贴相同的 Bundle Identifier!它像地狱一样工作。

【讨论】:

    【解决方案2】:

    Apple Developer Program 会员资格是必需的.

    来自:https://developer.apple.com/weatherkit/get-started/

    要求

    苹果开发者计划会员

    对 WeatherKit 测试版的访问包含在 Apple 开发者计划中, 它还提供了您需要的所有工具、资源和支持 开发和分发应用程序——包括访问测试版软件、应用程序 服务、测试工具、应用程序分析等。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-08-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-29
      • 1970-01-01
      • 2017-05-10
      • 2015-03-22
      相关资源
      最近更新 更多