Access iPhone settings from Unity?

Does anyone know how to access the iPhone settings from Unity in order to turn off / on the notifications setting for my app? Thanks

You can use the following native iOS (Objective-C )code. Note that it only works with iOS 8 or higher:

void OpenSettingsMenu() {
    if (&UIApplicationOpenSettingsURLString != NULL) {
        NSURL *appSettings = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
        [[UIApplication sharedApplication] openURL:appSettings];
    }
}

See this link for more details.

1 Like

Thanks, so is there any code to turn off the notifications without the user having to do it manually through their settings page?

I don’t think you can do that.

Ok. So this code gets entered in Unity or I have to put it somewhere in xCode?

Was wondering about this as I was in an app the other day and it took me directly to its specific settings so I could enable notifications. Thanks for the code snippet.

Do you know where in xCode this code should be put? And how do I then call it in Unity? Thanks

Read about native iOS plugins in the manual: Unity - Manual: Native plug-ins for iOS

In general this requires a few simple steps:

  • Add the native code to your Unity project. Starting with Unity 5, you can drop these files (an .m file and a matching .h header) anywhere in the project. The plugin inspector allows you to select which platforms these files are relevant for (in this case - iOS).
  • Define an “extern” method (with the DllImport attribute) like in the link above.
  • Call this method, which will result in calling the native method.

Hope this helps :slight_smile:

This is very helpful but I had been trying to find online the url string for the Ads tracking and app analytics page and I can’t find it anywhere. Any Ideas in how to access those pages?
Thanks in advance.