Opening the Settings app from another app

前端 未结 17 2459
傲寒
傲寒 2020-11-22 01:37

Okay, I know that there are many question about it, but they are all from many time ago.

So. I know that it is possible because the Map app does it.

In the M

17条回答
  •  旧时难觅i
    2020-11-22 02:12

    UIApplicationOpenSettingsURLString this will only work if you have previously allowed for any permission. For example Location, Photo, Contact, Push notification access. So if you have not such permission(s) from the user:

    If iOS 10 or above,

    It will open the Settings but then crash it. The reason, there's nothing in settings for your app.

    Below code will open your application settings inside the iOS Setting.

    NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
    if ([[UIApplication sharedApplication] canOpenURL:url]) {
        [[UIApplication sharedApplication] openURL:url];
    }
    

    Due to device unavailability, I couldn't check this on iOS < 10.

    Also, I could find below code from some gist and it works fine on iOS 10 as well. But I am not sure if this will approve by Apple review team or not.

    https://gist.github.com/johnny77221/bcaa5384a242b64bfd0b8a715f48e69f

提交回复
热议问题