Unity ads crash my iOS app when trying to show it

Error Message :

2017-04-26 13:20:25.419 gamename[318:32982] Uncaught exception: NSInvalidArgumentException: -[UnityAppController shouldAutorotate]: unrecognized selector sent to instance 0x1701135f0

(

0   CoreFoundation                      0x000000018d4a01d8 <redacted> + 148

1   libobjc.A.dylib                     0x000000018bed855c objc_exception_throw + 56

2   CoreFoundation                      0x000000018d4a7278 <redacted> + 0

3   CoreFoundation                      0x000000018d4a4278 <redacted> + 916

4   CoreFoundation                      0x000000018d39e59c _CF_forwarding_prep_0 + 92

5   gamename                 0x0000000100e5e3f0 +[UnityAds show:placementId:] + 292

6   gamename                 0x0000000100e5e2b0 +[UnityAds show:] + 100

7   gamename                 0x000000010010a148 -[UnityAppController(ViewHandling) ShowVideo:CurrentProviderVideo:] + 204

8   gamename                 0x000000010010ab70 _startShowVideo + 116

9   gamename                 0x0000000100126914 BannerAndInterstital_ShowVideo_m1287589967 + 352

10  gamename                 0x0000000100149fa8 GameControllerMenu_VideoForCoinsYes_m2986306505 + 76

11  gamename                 0x00000001003509cc InvokableCallList_Invoke_m575840373 + 264

12  gamename                 0x0000000100515218 ExecuteEvents_Execute_TisIl2CppObject_m1533897725_gshared + 836

13  gamename                 0x00000001003012dc StandaloneInputModule_ProcessTouchPress_m2953705401 + 960

14  gamename                 0x0000000100300e68 StandaloneInputModule_ProcessTouchEvents_m3567487943 + 312

15  gamename                 0x00000001003006f0 StandaloneInputModule_Process_m3720469665 + 116

16  gamename                 0x000000010057708c _Z31RuntimeInvoker_Void_t2863195528PK10MethodInfoPvPS2_ + 28

17  gamename                 0x0000000100e5561c _ZN6il2cpp2vm7Runtime6InvokeEPK10MethodInfoPvPS5_PP15Il2CppException + 68

18  gamename                 0x0000000100757b88 _ZN25ScriptingInvocationNoArgs6InvokeEPP18ScriptingException + 40

19  gamename                 0x0000000100757b54 _ZN25ScriptingInvocationNoArgs6InvokeEv + 32

20  gamename                 0x000000010074d0c0 _ZN13MonoBehaviour16CallUpdateMethodEi + 228

21  gamename                 0x000000010061ee94 _ZN20BaseBehaviourManager12CommonUpdateI16BehaviourManagerEEvv + 72

22  gamename                 0x0000000100706130 _Z10PlayerLoopbbP10IHookEvent + 1096

23  gamename                 0x0000000100961420 _ZL19UnityPlayerLoopImplb + 20

24  gamename                 0x00000001000f8954 UnityRepaint + 140

25  gamename                 0x00000001000f8850 -[UnityAppController(Rendering) repaintDisplayLink] + 88

26  GPUToolsCore                        0x0000000102a37b1c -[DYDisplayLinkInterposer forwardDisplayLinkCallback:] + 176

27  QuartzCore                          0x000000019069c640 <redacted> + 44

28  QuartzCore                          0x000000019069c4ec <redacted> + 444

29  IOKit                               0x000000018d70c570 IODispatchCalloutFromCFMessage + 372

30  CoreFoundation                      0x000000018d43656c <redacted> + 180

31  CoreFoundation                      0x000000018d44e934 <redacted> + 56

32  CoreFoundation                      0x000000018d44e0e8 <redacted> + 436

33  CoreFoundation                      0x000000018d44bbcc <redacted> + 1840

34  CoreFoundation                      0x000000018d37a048 CFRunLoopRunSpecific + 444

35  GraphicsServices                    0x000000018edfd198 GSEventRunModal + 180

36  UIKit                               0x000000019334d628 <redacted> + 684

37  UIKit                               0x0000000193348360 UIApplicationMain + 208

38  gamename                 0x00000001000f26ec main + 156

39  libdyld.dylib                       0x000000018c35c5b8 <redacted> + 4

)

Initialization Code called in CreateUI:

[UnityAds initialize:unityAppID delegate:self];

Delegats Code:

- (void)unityAdsReady:(NSString *)placementId

{

    unityAdsReady = TRUE;

    NSLog(@"unityRewardVideo:unityAdsReady: Video ready to be displayed PlacementID: %@", placementId);

}


-(void)unityAdsDidError:(UnityAdsError)error withMessage:(NSString *)message

{

    NSLog(@"unityRewardVideo:unityAdsDidError: %@", message);

    UnitySendMessage("RewardVideoManager", "UnityAdsVideoCompleted", "false");

}


-(void)unityAdsDidStart:(NSString *)placementId

{

    NSLog(@"unityRewardVideo:unityAdsDidStart: Video started PlacementID: %@", placementId);

}


-(void)unityAdsDidFinish:(NSString *)placementId withFinishState:(UnityAdsFinishState)state

{

    if (state != kUnityAdsFinishStateSkipped) {

        UnitySendMessage("RewardVideoManager", "UnityAdsVideoCompleted", "true");

        NSLog(@"unityRewardVideo:unityAdsDidFinish: Video compleated PlacementID: %@", placementId);

    }

    else

    {

        UnitySendMessage("RewardVideoManager", "UnityAdsVideoCompleted", "false");

        NSLog(@"unityRewardVideo:unityAdsDidFinish: Video skipped PlacementID: %@", placementId);

    }

}

Code used to show the video :

- (void) showUnityVideoAd

{

    NSLog(@"Show Unity Reward Video");

    if (unityAdsReady)

    {

        NSLog(@"Showing Unity Reward Video");

        [UnityAds show:thisClass];

    }

    else

    {

        NSLog(@"Not Ready Unity Reward Video");

        [self ShowVideo:rage:"" CurrentProviderVideo:-1];

    }

}

Xcode whose build using Unity 5.4.1f1
Xcode version 7.2.1
UnityAds version 2.1.0

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?

Thanks for the replay the class whose set up perfectly, the fix whose changing
this
[UnityAds show:thisClass];
to this
[UnityAds show:[thisClass topMostController]];