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

Unity ads crash my iOS app when trying to show it

Discussion in 'Unity Ads & User Acquisition' started by TheEye2108, Apr 26, 2017.

  1. TheEye2108

    TheEye2108

    Joined:
    Dec 25, 2015
    Posts:
    22
    Error Message :
    Code (CSharp):
    1.  

    Initialization Code called in CreateUI:

    Code (CSharp):
    1. [UnityAds initialize:unityAppID delegate:self];

    Delegats Code:

    Code (CSharp):
    1. - (void)unityAdsReady:(NSString *)placementId
    2.  
    3. {
    4.  
    5.     unityAdsReady = TRUE;
    6.  
    7.     NSLog(@"unityRewardVideo:unityAdsReady: Video ready to be displayed PlacementID: %@", placementId);
    8.  
    9. }
    10.  
    11.  
    12. -(void)unityAdsDidError:(UnityAdsError)error withMessage:(NSString *)message
    13.  
    14. {
    15.  
    16.     NSLog(@"unityRewardVideo:unityAdsDidError: %@", message);
    17.  
    18.     UnitySendMessage("RewardVideoManager", "UnityAdsVideoCompleted", "false");
    19.  
    20. }
    21.  
    22.  
    23. -(void)unityAdsDidStart:(NSString *)placementId
    24.  
    25. {
    26.  
    27.     NSLog(@"unityRewardVideo:unityAdsDidStart: Video started PlacementID: %@", placementId);
    28.  
    29. }
    30.  
    31.  
    32. -(void)unityAdsDidFinish:(NSString *)placementId withFinishState:(UnityAdsFinishState)state
    33.  
    34. {
    35.  
    36.     if (state != kUnityAdsFinishStateSkipped) {
    37.  
    38.         UnitySendMessage("RewardVideoManager", "UnityAdsVideoCompleted", "true");
    39.  
    40.         NSLog(@"unityRewardVideo:unityAdsDidFinish: Video compleated PlacementID: %@", placementId);
    41.  
    42.     }
    43.  
    44.     else
    45.  
    46.     {
    47.  
    48.         UnitySendMessage("RewardVideoManager", "UnityAdsVideoCompleted", "false");
    49.  
    50.         NSLog(@"unityRewardVideo:unityAdsDidFinish: Video skipped PlacementID: %@", placementId);
    51.  
    52.     }
    53.  
    54. }
    Code used to show the video :
    Code (CSharp):
    1. - (void) showUnityVideoAd
    2.  
    3. {
    4.  
    5.     NSLog(@"Show Unity Reward Video");
    6.  
    7.     if (unityAdsReady)
    8.  
    9.     {
    10.  
    11.         NSLog(@"Showing Unity Reward Video");
    12.  
    13.         [UnityAds show:thisClass];
    14.  
    15.     }
    16.  
    17.     else
    18.  
    19.     {
    20.  
    21.         NSLog(@"Not Ready Unity Reward Video");
    22.  
    23.         [self ShowVideo:mad:"" CurrentProviderVideo:-1];
    24.  
    25.     }
    26.  
    27. }
    Xcode whose build using Unity 5.4.1f1
    Xcode version 7.2.1
    UnityAds version 2.1.0
     
  2. FritzH

    FritzH

    Developer Relations Unity Technologies

    Joined:
    Aug 18, 2015
    Posts:
    45
    On iOS, the the show() method expects a UIViewController, or another class that implements shouldAutorotate.

    I'm guessing "thisClass" is not a subclass of UIViewController?
     
  3. TheEye2108

    TheEye2108

    Joined:
    Dec 25, 2015
    Posts:
    22
    Thanks for the replay the class whose set up perfectly, the fix whose changing
    this
    [UnityAds show:thisClass];
    to this
    [UnityAds show:[thisClass topMostController]];