Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

[RESOLVED]IOS crash when open App Settings via native

Discussion in 'iOS and tvOS' started by BrokenAngel, Oct 29, 2019.

  1. BrokenAngel

    BrokenAngel

    Joined:
    Mar 24, 2013
    Posts:
    92
    Hi guys, so I have and option that user can click on it and navigate to App settings on IOS in order to turn on notification.

    So here is a quick view of my native code

    Code (CSharp):
    1. #define onMainThread(_lambda) \
    2. if([NSThread isMainThread]){ \
    3. _lambda \
    4. } else { \
    5. dispatch_async(dispatch_get_main_queue(), ^{ \
    6. _lambda \
    7. }); \
    8. }
    9.  
    10. const void _showNotificationSettings()
    11. {
    12.     onMainThread({
    13.             NSURL * url = [NSURL URLWithString: UIApplicationOpenSettingsURLString];
    14.             if([[UIApplication sharedApplication] canOpenURL:url])
    15.             {
    16.                 [[UIApplication sharedApplication] openURL:url];
    17.             }
    18.         };);
    19. }
    Whenever this code is execute it bring me to the app settings correctly but also causing my application crashes.

    If anyone had done this please help me out.
     
  2. BrokenAngel

    BrokenAngel

    Joined:
    Mar 24, 2013
    Posts:
    92
    I had fixed this.

    Thanks.