2017-10-10 92 views
0

我該如何將用戶從我的應用程序轉到郵件設置?我知道要使用的代碼,但我不知道具體的字符串字面值,以與UIApplication.shared.open(URL:options :)方法一起創建正確的URL。我認爲文字需要以「prefs:root =」開頭。它需要如下所示。我只需要知道使用什麼文字而不是「消息」。如何將iOS應用程序中的用戶添加到消息設置中?

let urlString = "prefs:root=Messages" 

    let url = URL(string: urlString)! 

    let options: [String: Any] = [:] 
    UIApplication.shared.open(url, options: options) { 

     bool in 

     print(bool) 

    } 

回答

0

我想通了。我必須使用字符串文字「App-Prefs:root = MESSAGES」。

0
let url = URL(string: "prefs:root=MESSAGES")! 
UIApplication.shared.openURL(url) 

將打開設置 - >信息

+0

我已經試過了。直到我將字符串文字更改爲「App-Prefs:root = MESSAGES」,它才起作用。我不知道爲什麼。我發現文檔說的是你說的同樣的東西。 – ShinehahGnolaum

相關問題