9
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Swift5を使ってURLスキームで設定画面に遷移する方法

Posted at

初めに

今回はURLスキームを使って設定画面に遷移させる方法を記事にします。
Appleに申請した時あるコードを使うとリジェクトする話もしたいと思います。

実装

以下が設定画面の遷移コードです。

test.swift
guard let settingsUrl = URL(string: UIApplication.openSettingsURLString) else {
  return
}
if UIApplication.shared.canOpenURL(settingsUrl)  {
  if #available(iOS 10.0, *) {
    UIApplication.shared.open(settingsUrl, completionHandler: { (success) in
    })
  }
  else  {
    UIApplication.shared.openURL(settingsUrl)
  }
}

リジェクトするコードの実装

以下がリジェクトの対象コードです。
同じく設定画面にこちらからも遷移できますが、リリースする場合はこちらのコードはNGです。

test.swift
if let url = URL(string:"App-Prefs:root=NOTIFICATIONS_ID&path={ビルドID}") {
    if #available(iOS 10.0, *) {
        UIApplication.shared.open(url, options: [:], completionHandler: nil)
    } else {
        UIApplication.shared.openURL(url)
    }
}

実際のAPPLEのエラー

ちなみに、リジェクト対象のコードで申請すると下記のエラーで怒られます。。。。。

Guideline 2.5.1 - Performance - Software Requirements


Your app uses the "prefs:root=" non-public URL scheme, 
which is a private entity. 
The use of non-public APIs is not permitted on the App Store because it can lead to a poor user experience should these APIs change.

Specifically, 
your app uses the following non-public URL scheme:

app-prefs:root=notifications_id&path=

Next Steps

To resolve this issue, 
please revise your app to provide the associated functionality using public APIs or remove the functionality using the
 "prefs:root" or "App-Prefs:root" URL scheme.


#終わり
今回は設定画面に遷移する方法を紹介しました。
リジェクトするとリリースまで期間が延びちゃうのでそこら辺は慎重にしたいですね。

9
10
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
9
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?