LoginSignup
3
2

More than 3 years have passed since last update.

【iOS】Dropbox iOS13対応

Last updated at Posted at 2020-04-01

はじめに

・iOS13用にDropboxを対応したところ、ハマったので備忘録として記載。

環境

xcode11.0
swift 5.0.1
iOS13

これまで

・チュートリアル通りに進むと

AppDelegate.swift
  func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
      if let authResult = DropboxClientsManager.handleRedirectURL(url) {
          switch authResult {
          case .success:
              print("Success! User is logged into Dropbox.")
          case .cancel:
              print("Authorization flow was manually canceled by user!")
          case .error(_, let description):
              print("Error: \(description)")
          }
      }
      return true
  }

と記載していた。
iOS13ではSceneDelegate.swiftに移譲された為、変更が必要になる。

これから

・SceneDelegate.swiftへ以下を記載。

SceneDelegate.swift

    func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>)
    {

      // コールバックで来たURLの取得
      guard let url = URLContexts.first?.url else {
          return
      }

      if let authResult = DropboxClientsManager.handleRedirectURL(url) {
          switch authResult {
          case .success:
              print("Success! User is logged into Dropbox.")
          case .cancel:
              print("Authorization flow was manually canceled by user!")
          case .error(_, let description):
              print("Error: \(description)")
          }
      }
      return
  }

まとめ

・iOS13とそれ以前のiOSを対応させるように作成した為、AppDelegateが原因であることに気づくのに時間がかかった。
大型アップデート後の情報収集は怠ってはならない教訓になりました。

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2