Open Wifi Settings programatically from pop-up notification











up vote
1
down vote

favorite












I'm using the code snippet below, but it does not seem to open the Settings, it opens the Notifications settings of the app.



I need to open the wifi settings to enable the user to switch it off, iOS 12, Swift 4.2



{

if response.actionIdentifier == "action1" {
guard let settingsUrl = URL(string: UIApplication.openSettingsURLString) else {
return
}

if UIApplication.shared.canOpenURL(settingsUrl) {
UIApplication.shared.open(settingsUrl, completionHandler: { (success) in
print("Settings opened: (success)") // Prints true
})
}
}
}









share|improve this question
























  • Have you tried this ? stackoverflow.com/a/34024467/5464805
    – Olympiloutre
    Nov 13 at 9:59










  • You can not open Wifi-Settings directly. Apple only allows to open settings. There are many answers to open Wifi-settings only but then your app will get rejection if the reviewer noticed this behavior.
    – Kamran
    Nov 13 at 10:00












  • Possible duplicate of How to open WIFI setting in Swift 3
    – Kamran
    Nov 13 at 10:01










  • I'm getting this when compiling the code with the suggested link [stackoverflow.com/questions/39764553/…: UIApplicationOpenSettingsURLString' has been renamed to 'UIApplication.openSettingsURLString This opens "Allow AppName to access:" and not the General Settings Page
    – shawn.t
    Nov 13 at 12:51










  • The method in the link opens the App's settings, not the phone's settings. How do I open the phone's settings?
    – shawn.t
    Nov 13 at 13:08















up vote
1
down vote

favorite












I'm using the code snippet below, but it does not seem to open the Settings, it opens the Notifications settings of the app.



I need to open the wifi settings to enable the user to switch it off, iOS 12, Swift 4.2



{

if response.actionIdentifier == "action1" {
guard let settingsUrl = URL(string: UIApplication.openSettingsURLString) else {
return
}

if UIApplication.shared.canOpenURL(settingsUrl) {
UIApplication.shared.open(settingsUrl, completionHandler: { (success) in
print("Settings opened: (success)") // Prints true
})
}
}
}









share|improve this question
























  • Have you tried this ? stackoverflow.com/a/34024467/5464805
    – Olympiloutre
    Nov 13 at 9:59










  • You can not open Wifi-Settings directly. Apple only allows to open settings. There are many answers to open Wifi-settings only but then your app will get rejection if the reviewer noticed this behavior.
    – Kamran
    Nov 13 at 10:00












  • Possible duplicate of How to open WIFI setting in Swift 3
    – Kamran
    Nov 13 at 10:01










  • I'm getting this when compiling the code with the suggested link [stackoverflow.com/questions/39764553/…: UIApplicationOpenSettingsURLString' has been renamed to 'UIApplication.openSettingsURLString This opens "Allow AppName to access:" and not the General Settings Page
    – shawn.t
    Nov 13 at 12:51










  • The method in the link opens the App's settings, not the phone's settings. How do I open the phone's settings?
    – shawn.t
    Nov 13 at 13:08













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I'm using the code snippet below, but it does not seem to open the Settings, it opens the Notifications settings of the app.



I need to open the wifi settings to enable the user to switch it off, iOS 12, Swift 4.2



{

if response.actionIdentifier == "action1" {
guard let settingsUrl = URL(string: UIApplication.openSettingsURLString) else {
return
}

if UIApplication.shared.canOpenURL(settingsUrl) {
UIApplication.shared.open(settingsUrl, completionHandler: { (success) in
print("Settings opened: (success)") // Prints true
})
}
}
}









share|improve this question















I'm using the code snippet below, but it does not seem to open the Settings, it opens the Notifications settings of the app.



I need to open the wifi settings to enable the user to switch it off, iOS 12, Swift 4.2



{

if response.actionIdentifier == "action1" {
guard let settingsUrl = URL(string: UIApplication.openSettingsURLString) else {
return
}

if UIApplication.shared.canOpenURL(settingsUrl) {
UIApplication.shared.open(settingsUrl, completionHandler: { (success) in
print("Settings opened: (success)") // Prints true
})
}
}
}






ios swift unusernotificationcenter






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 at 10:07

























asked Nov 13 at 9:42









shawn.t

255




255












  • Have you tried this ? stackoverflow.com/a/34024467/5464805
    – Olympiloutre
    Nov 13 at 9:59










  • You can not open Wifi-Settings directly. Apple only allows to open settings. There are many answers to open Wifi-settings only but then your app will get rejection if the reviewer noticed this behavior.
    – Kamran
    Nov 13 at 10:00












  • Possible duplicate of How to open WIFI setting in Swift 3
    – Kamran
    Nov 13 at 10:01










  • I'm getting this when compiling the code with the suggested link [stackoverflow.com/questions/39764553/…: UIApplicationOpenSettingsURLString' has been renamed to 'UIApplication.openSettingsURLString This opens "Allow AppName to access:" and not the General Settings Page
    – shawn.t
    Nov 13 at 12:51










  • The method in the link opens the App's settings, not the phone's settings. How do I open the phone's settings?
    – shawn.t
    Nov 13 at 13:08


















  • Have you tried this ? stackoverflow.com/a/34024467/5464805
    – Olympiloutre
    Nov 13 at 9:59










  • You can not open Wifi-Settings directly. Apple only allows to open settings. There are many answers to open Wifi-settings only but then your app will get rejection if the reviewer noticed this behavior.
    – Kamran
    Nov 13 at 10:00












  • Possible duplicate of How to open WIFI setting in Swift 3
    – Kamran
    Nov 13 at 10:01










  • I'm getting this when compiling the code with the suggested link [stackoverflow.com/questions/39764553/…: UIApplicationOpenSettingsURLString' has been renamed to 'UIApplication.openSettingsURLString This opens "Allow AppName to access:" and not the General Settings Page
    – shawn.t
    Nov 13 at 12:51










  • The method in the link opens the App's settings, not the phone's settings. How do I open the phone's settings?
    – shawn.t
    Nov 13 at 13:08
















Have you tried this ? stackoverflow.com/a/34024467/5464805
– Olympiloutre
Nov 13 at 9:59




Have you tried this ? stackoverflow.com/a/34024467/5464805
– Olympiloutre
Nov 13 at 9:59












You can not open Wifi-Settings directly. Apple only allows to open settings. There are many answers to open Wifi-settings only but then your app will get rejection if the reviewer noticed this behavior.
– Kamran
Nov 13 at 10:00






You can not open Wifi-Settings directly. Apple only allows to open settings. There are many answers to open Wifi-settings only but then your app will get rejection if the reviewer noticed this behavior.
– Kamran
Nov 13 at 10:00














Possible duplicate of How to open WIFI setting in Swift 3
– Kamran
Nov 13 at 10:01




Possible duplicate of How to open WIFI setting in Swift 3
– Kamran
Nov 13 at 10:01












I'm getting this when compiling the code with the suggested link [stackoverflow.com/questions/39764553/…: UIApplicationOpenSettingsURLString' has been renamed to 'UIApplication.openSettingsURLString This opens "Allow AppName to access:" and not the General Settings Page
– shawn.t
Nov 13 at 12:51




I'm getting this when compiling the code with the suggested link [stackoverflow.com/questions/39764553/…: UIApplicationOpenSettingsURLString' has been renamed to 'UIApplication.openSettingsURLString This opens "Allow AppName to access:" and not the General Settings Page
– shawn.t
Nov 13 at 12:51












The method in the link opens the App's settings, not the phone's settings. How do I open the phone's settings?
– shawn.t
Nov 13 at 13:08




The method in the link opens the App's settings, not the phone's settings. How do I open the phone's settings?
– shawn.t
Nov 13 at 13:08












1 Answer
1






active

oldest

votes

















up vote
0
down vote













Open settings, don't open wifi setting. My app was rejected once when i opened wifi setting directly from my app. Avoid using private apis, apple may reject your app.






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53278042%2fopen-wifi-settings-programatically-from-pop-up-notification%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    Open settings, don't open wifi setting. My app was rejected once when i opened wifi setting directly from my app. Avoid using private apis, apple may reject your app.






    share|improve this answer

























      up vote
      0
      down vote













      Open settings, don't open wifi setting. My app was rejected once when i opened wifi setting directly from my app. Avoid using private apis, apple may reject your app.






      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        Open settings, don't open wifi setting. My app was rejected once when i opened wifi setting directly from my app. Avoid using private apis, apple may reject your app.






        share|improve this answer












        Open settings, don't open wifi setting. My app was rejected once when i opened wifi setting directly from my app. Avoid using private apis, apple may reject your app.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 13 at 10:08









        Viren Malhan

        424




        424






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53278042%2fopen-wifi-settings-programatically-from-pop-up-notification%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            How to change which sound is reproduced for terminal bell?

            Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

            Can I use Tabulator js library in my java Spring + Thymeleaf project?