Search Unity

Unity Ads don't work on iOS

Discussion in 'Unity Ads' started by vvoojj, Apr 30, 2016.

  1. vvoojj

    vvoojj

    Joined:
    Apr 23, 2015
    Posts:
    6
    Unity Ads on android work but on iOS don't work. I was set platform iOS. Use unity 5.3.3 on PC and 5.3.4 on mac
     

    Attached Files:

    • ads.png
      ads.png
      File size:
      77.8 KB
      Views:
      936
  2. mikaisomaa

    mikaisomaa

    Unity Technologies

    Joined:
    Sep 14, 2015
    Posts:
    365
    Hi,

    Under the advanced tab, you'll find the game IDs used to initialize Unity Ads. Can you provide me with those game IDs?

    Can I see your code responsible for handling Unity Ads?

    I'll get back to you after your response.

    Kind regards,
     
  3. vvoojj

    vvoojj

    Joined:
    Apr 23, 2015
    Posts:
    6
    Hi,

    My project id: f1316bbc-8e0b-4113-847a-c3fbe88a8c09

    When was run game have debug text:

    2016-05-02 12:45:43.126 UUOneGuy[959:907] Unity Ads is ready to show ads

    2016-05-02 12:45:43.158 UUOneGuy[959:907] Launching ad from video, options: {

    allowClientOverrides = (

    noOfferScreen,

    openAnimated,

    muteVideoSounds,

    useDeviceOrientationForVideo

    );

    allowSkipVideoInSeconds = 5;

    allowVideoSkipInSeconds = 5;

    default = 1;

    defaultRewardItem = {

    key = default;

    name = "Default reward item";

    picture = "https://static.applifier.com/unityads/unityicon_62.png";

    };

    deleted = 0;

    disableBackButtonForSeconds = 30;

    enabled = 1;

    id = video;

    incentivised = 0;

    muteVideoSounds = 0;

    name = Video;

    noOfferScreen = 1;

    openAnimated = 0;

    rewardItems = (

    {

    key = default;

    name = "Default reward item";

    picture = "https://static.applifier.com/unityads/unityicon_62.png";

    }

    );

    useDeviceOrientationForVideo = 1;

    }

    2016-05-02 12:45:43.198 UUOneGuy[959:907] Warning: Attempt to present <UnityAdsMainViewController: 0x1de76420> on <UnityDefaultViewController: 0x1c541ae0> whose view is not in the window hierarchy!

    2016-05-02 12:45:43.744 UUOneGuy[959:907] You are using download over http. Currently unity adds NSAllowsArbitraryLoads to Info.plist to simplify transition, but it will be removed soon. Please consider updating to https.

    For show ads use this code:

    public static void ShowAd()
    {
    if (Advertisement.IsReady ()) {
    Advertisement.Show ();
    }
    }
     
  4. mikaisomaa

    mikaisomaa

    Unity Technologies

    Joined:
    Sep 14, 2015
    Posts:
    365
    Hi,

    You provided the project ID.

    For avoidance of doubt, can you provide me with your game ID(s) - they're located under the advanced tab in your services window -> ads.
     
  5. vvoojj

    vvoojj

    Joined:
    Apr 23, 2015
    Posts:
    6
    iOS GameID: 1055422
     
  6. mikaisomaa

    mikaisomaa

    Unity Technologies

    Joined:
    Sep 14, 2015
    Posts:
    365
    I couldn't find any issues on our end that could be the cause of this.

    Have you tested this on the device? Are you by chance calling the show() function too early - before Unity Ads has had time to initialize?

    Is your device connected to the Internet?
     
  7. vvoojj

    vvoojj

    Joined:
    Apr 23, 2015
    Posts:
    6
    Yes I tested on the device. Show calling after the initialize. Device have connection of internet(other internet functions are working). Can be problem in iOS name project is "UUOneGuy" but in Unity "EEOneGuy (2)"?
     
  8. mikaisomaa

    mikaisomaa

    Unity Technologies

    Joined:
    Sep 14, 2015
    Posts:
    365
    Does the IsReady() -function return true or false?

    In case it's returning false, I'd recommend waiting further after initializing ads - as it may take a while to download the campaign data.
     
  9. vvoojj

    vvoojj

    Joined:
    Apr 23, 2015
    Posts:
    6
    I was delete this line " Screen.orientation=ScreenOrientation.Portrait;" and ads start work. But need portrait orientation. How can use portrait orientation with unity abs?
     
  10. FritzH

    FritzH

    Developer Relations Unity Technologies

    Joined:
    Aug 18, 2015
    Posts:
    45
    In the dashboard, there's an option to use device's orientation instead of forcing landscape.

    Once enabled, your app should be able to display portrait ads.
     
    unity-nikkolai likes this.
  11. vvoojj

    vvoojj

    Joined:
    Apr 23, 2015
    Posts:
    6
    This is don't work.
     
  12. Mikea15

    Mikea15

    Joined:
    Sep 20, 2012
    Posts:
    93
    Hey!

    I'm currently experiencing the same issue. Ads do not show up on iOS devices, but they work just fine on Android. On the Editor, the default ads placement appear, they just don't work on iOS devices.

    Code (CSharp):
    1. if( Advertisement.IsReady() )
    2.         {
    3.             Advertisement.Show(null, new ShowOptions() {
    4.                 resultCallback = result => {
    5.                     ReceiveBonusForWatchingVideoAds();
    6.                 }
    7.             });
    8.         }
    Sample code for displaying ads.
     
  13. mikaisomaa

    mikaisomaa

    Unity Technologies

    Joined:
    Sep 14, 2015
    Posts:
    365
    Hi Mikea,

    How are you initializing the ads? Are you using the iOS game ID for iOS?
     
  14. Mikea15

    Mikea15

    Joined:
    Sep 20, 2012
    Posts:
    93
    Well I was using the old way of initializing the Ads, but since it has been integrated within the editor, I've removed that piece of code, since it should automatically initilize the ads, right?

    Code (CSharp):
    1. #if UNITY_ANDROID || UNITY_IOS
    2.         Advertisement.Initialize("--ProjectCodeIntHere--");
    3. #endif
    ( this is what I had.. with the proper code id for the project )

    (link = http://docs.unity3d.com/Manual/UnityAdsHowTo.html )
     
    Last edited: May 3, 2016
  15. mikaisomaa

    mikaisomaa

    Unity Technologies

    Joined:
    Sep 14, 2015
    Posts:
    365
    Hi,

    Remember that the Game ID is different for both platforms (Android & iOS) - for the services window -based integration, these are found under Window -> Unity Services -> Ads -> Advanced tab

    The Game IDs are platform -specific, so you need to use an iOS game ID for your iOS game.
     
  16. Mikea15

    Mikea15

    Joined:
    Sep 20, 2012
    Posts:
    93
    I know they are platform specific. The old dashboard had a unique ID for the project. ( no using since long time ago ;) ) But! Since I don't need to manually initialize the Ads ( Correct me on this ). I shouldn't be able to mess with *any* ID. And both IDs are the same on the Services Tab, and on the New Dashboard..

    So why exactly everything works on Android and not on iOS ? :/
     
    daviddickball likes this.
  17. mikaisomaa

    mikaisomaa

    Unity Technologies

    Joined:
    Sep 14, 2015
    Posts:
    365
    Hi,

    So you're saying the IDs are the same on the dashboard and the services window, but not equal to each other?

    Can you provide me with the game IDs so that I can take a closer look?

    You don't need to manually initialize ads when using the services window -based integration, but you can change the game IDs in the services window -> ads -> advanced tab.

    I just want to make sure you're using the iOS game ID for the iOS build first.

    Your iOS device also has a functioning Internet connection?

    Have you checked the log output from the iOS device? Can you provide me with the xcode logs?
     
  18. Mikea15

    Mikea15

    Joined:
    Sep 20, 2012
    Posts:
    93
    Exaclty yes, my iOS GameID = 1003298, and Android GameID = 1003297. I assume these where auto-generated?
    ( Project ID: 346a1310-c3e8-4aa0-b2f8-7fac4207c7dd )

    Also, yes, I have wifi enabled on the phone, and/or 4G. The log on iOS I can provide later during the day, since I'm not on my Mac, but It shows something similar vvoojj 's post above ( http://forum.unity3d.com/threads/unity-ads-dont-work-on-ios.401247/#post-2618687 ). I can see that something is called but nothing shows on screen.

    I'll try to get that log as soon as I can. Also, should the IDs be the same for both platforms? Aren't you filtering by platform with these ids?
     
  19. mikaisomaa

    mikaisomaa

    Unity Technologies

    Joined:
    Sep 14, 2015
    Posts:
    365
    Thanks for providing these. Yes, we generate the game IDs for each platform automatically. You can still change them though. You should use an iOS game ID on an iOS game and the same goes for Android. When we generate these two IDs for you - the IDs are off by one from each other.

    I checked the stats for your game and it shows ad requests up to yesterday, but completed impressions only until 29. of March.

    If you can provide the build as well as the logs - it could help troubleshoot the issue further.

    You can also contact the support directly and send the project for inspection if this issue still persists.
     
  20. Mikea15

    Mikea15

    Joined:
    Sep 20, 2012
    Posts:
    93
    I'll post the logs later today. As for the build, I'm currently on testflight, if you have an iOS device I can send it to, PM me the email and I'll add it to the list. ( Assuming you can check directly the calls to the api, and see it in realtime ).
     
  21. Mikea15

    Mikea15

    Joined:
    Sep 20, 2012
    Posts:
    93
    @mikaisomaa

    Hey, so as promised heres the log of failing to show ads on iOS.
    This time, I've made a Debug Build and compiled with Mono instead of Ill2cpp. Same result tho, just better message logs.

    http://pastebin.com/6Wx5Eu8T

    The ads are getting initialized with the correct game id, for the correct platform.
    Line 190.
    So its launching the video ads, and nothing apears.

    Then if I re-click the button to show the ads.
    Comming from code looking like this:
    Code (CSharp):
    1. public void ShopWatchVideoAdd( )
    2. {
    3.   if( Advertisement.IsReady() )
    4.   {
    5.     Advertisement.Show(null, new ShowOptions() {
    6.       resultCallback = result => {
    7.         ReceiveBonusForWatchingVideoAds();
    8.       }
    9.     });
    10.   }
    11.   else
    12.   {
    13.     Debug.Log("Guess not.");
    14.   }
    15. }
    Any idea? :/

    Is there a problem with views on iOS side of things? This makes me think a view is misplaced:
    Line 227:
    Cheers.
     
  22. Mikea15

    Mikea15

    Joined:
    Sep 20, 2012
    Posts:
    93
    @mikaisomaa hey, did you had the chance to check this out?
     
  23. Mikea15

    Mikea15

    Joined:
    Sep 20, 2012
    Posts:
    93
    Update: I was able to fix this issue removing all code related to screen.orientation. Apparently, as soon as you set screen orientation, on iOS the adsView will be removed from the hierarchy and will not display.

    @mikaisomaa ;)
     
    unity-nikkolai and mikaisomaa like this.
  24. mikaisomaa

    mikaisomaa

    Unity Technologies

    Joined:
    Sep 14, 2015
    Posts:
    365
    Hi,

    Thanks for bringing this up! I've passed this on to the right hands.
     
    Mikea15 likes this.
  25. stonecompass

    stonecompass

    Joined:
    Aug 5, 2015
    Posts:
    13
    Any fixes for this if you still only want your game to be in portrait mode?

    No ads are displaying on my iOS-devices atm :-(
     
    Last edited: Jul 14, 2016
  26. mikaisomaa

    mikaisomaa

    Unity Technologies

    Joined:
    Sep 14, 2015
    Posts:
    365
    Hi,

    Can you try this: go to the dashboard -> select project -> platform -> settings -> "use video orientation according to the orientation of the device": ON

    Let me know if this works for you as well.
     
  27. stonecompass

    stonecompass

    Joined:
    Aug 5, 2015
    Posts:
    13
    I tried it and unfortunately it didn't work. I should mention that I'm using the newest Unity beta (25). Would it help to switch back to 5.3?
     
  28. screenname_taken

    screenname_taken

    Joined:
    Apr 8, 2013
    Posts:
    635
    @mikaisomaa I have the same issue, and the ads are set to show according to the device's orientation.
    (sent you a pm days ago :))

    This is what XCode has to say when it's time to show the ads:
    "
    2016-07-17 17:08:54.876 AdvBall[749:229364] Warning: Attempt to present <UnityAdsMainViewController: 0x1569a6a50> on <UnityLandscapeRightOnlyViewController: 0x1556f7b00> whose view is not in the window hierarchy!
    "


    And yes, the ads show as they should in Android. EveryPlay also works on android but not on iOS :/ c'mon guys these two stuff are what i'd like to implement to help my game make something out of it.

    *Edit*: The ads don't show only if the player chooses to flip the screen.
    I have such an option because some devices have the speaker in such a way that will muffle the sound if you hold the phone in a certain way.
    So they can flip the screen if they want in case the headphones cable is in the way or the speaker is muffled by their hands.

    *Edit #2:* I stopped the editor from autoinitialising the ads, and initialised them after the script that sets the orientation runs. Ads worked.

    *Edit #3*: I removed the edits from number2, and only changed the orientation options in Xcode. I enabled both landscape options. Ads did NOT work.

    So, the stuff in Edit #2 did the trick.
     
    Last edited: Jul 17, 2016
    stonecompass likes this.
  29. bkilby

    bkilby

    Joined:
    Oct 2, 2013
    Posts:
    1
    @screenname_taken How were you able to stop the auto initialize? I am having a similar issue and I'm wondering if that would help me too.
     
  30. screenname_taken

    screenname_taken

    Joined:
    Apr 8, 2013
    Posts:
    635
    I did a search in here and there was a cs script for thr editor that would stop them. I'm not at the pc atm to copy paste it. It enables them but won't initialize them till you do it manually. The documentation also has something for it i think.
     
  31. stonecompass

    stonecompass

    Joined:
    Aug 5, 2015
    Posts:
    13
    I tried the cs-script that should disable it, but it still initialized it on startup :-(
    Code (CSharp):
    1.  
    2. public class UnityAdsBuildProcessor : Editor
    3. {
    4.     [PostProcessScene]
    5.     public static void OnPostprocessScene ()
    6.     {
    7.         AdvertisementSettings.enabled = true;
    8.         AdvertisementSettings.initializeOnStartup = false;
    9.     }
    10. }
    [/QUOTE][/code]
     
  32. screenname_taken

    screenname_taken

    Joined:
    Apr 8, 2013
    Posts:
    635
    Did you put it in "Editor" folder?
     
  33. stonecompass

    stonecompass

    Joined:
    Aug 5, 2015
    Posts:
    13
    Yes, I did. Maybe I did something wrong, so I'll try it out again later today! :)
     
  34. stonecompass

    stonecompass

    Joined:
    Aug 5, 2015
    Posts:
    13
    What version of Unity are you using? Maybe I should try another version, since I'm currently using the beta, which on second thought might not be a good idea.
     
  35. screenname_taken

    screenname_taken

    Joined:
    Apr 8, 2013
    Posts:
    635
    I'm also using 5.4
     
  36. stonecompass

    stonecompass

    Joined:
    Aug 5, 2015
    Posts:
    13
    That's strange. And you have Ads turned on through the Services-window? You're not using the old package?
     
    Last edited: Jul 18, 2016
  37. screenname_taken

    screenname_taken

    Joined:
    Apr 8, 2013
    Posts:
    635
    through the services. And i call the initialize call after the game checks or sets the screen orientation.
    I think the ads documentation mentions the "call it later" thing?
     
  38. screenname_taken

    screenname_taken

    Joined:
    Apr 8, 2013
    Posts:
    635
    Ok i just noticed something. If i start the game, it's fine, it shows the ads. If i then go and flip the screen, it won't show the ads. But if i restart the app, the previously non working ads/orientation will work again.
    Any input @mikaisomaa ? :/
     
  39. stonecompass

    stonecompass

    Joined:
    Aug 5, 2015
    Posts:
    13
    How do you know that it has set the screen orientation? Do you initialize in a script or do you add the initialization line when the code is open in Xcode?
     
  40. screenname_taken

    screenname_taken

    Joined:
    Apr 8, 2013
    Posts:
    635
    Script. I have it on load to check player prefs for the orientation that the user prefers and set it. So it does that every time the game loads the first scene. Once that is checked and set, i then call the advertisement class to initialize, so hopefully it starts the ads after the game sets it's orientation. Now, it shows the ads in both landscape modes. Before that it wouldn't. Though it seems it's still not perfect because if you start the game, go in a stage, and then go back to the menu and change the orientation it doesn't work.
    It seems the ads would need to stop and restart when that happens.
     
  41. stonecompass

    stonecompass

    Joined:
    Aug 5, 2015
    Posts:
    13
    Oh okay, that seems like strange behaviour. Any news @mikaisomaa ?
     
  42. mikaisomaa

    mikaisomaa

    Unity Technologies

    Joined:
    Sep 14, 2015
    Posts:
    365
    Hi,

    This orientation bug is a known issue and is resolved in our upcoming SDK release.

    In the meantime - there's two workarounds:
    - If you're in the new dashboard, you can go to project -> platform -> settings and choose "use video orientation according to the orientation of the device" - this should help
    - Use the Asset Store package version of Unity Ads

    I hope this helps!
     
    Last edited: Jul 19, 2016
    stonecompass likes this.
  43. stonecompass

    stonecompass

    Joined:
    Aug 5, 2015
    Posts:
    13
    Sounds good. Any idea when the SDK will be released?

    Thanks for the workarounds. The first one didn't work for me, but I'll try the other one!
     
  44. mikaisomaa

    mikaisomaa

    Unity Technologies

    Joined:
    Sep 14, 2015
    Posts:
    365
    stonecompass likes this.
  45. stonecompass

    stonecompass

    Joined:
    Aug 5, 2015
    Posts:
    13
    Will do. Thank you!
     
  46. screenname_taken

    screenname_taken

    Joined:
    Apr 8, 2013
    Posts:
    635
    I also have the video option set like that. Will try the beta as well later today. MY 1070 JUST CAME IN WOOOOO
     
  47. stonecompass

    stonecompass

    Joined:
    Aug 5, 2015
    Posts:
    13
    Nice! I just integrated the SDK 2.0 beta, but I still don't get any ads on my iOS device :(

    EDIT: It works. I was building through the XCode beta onto my iPhone 6S which is running the iOS 10 beta. But it worked on my iPad that is still running iOS 9.3.2 :)
     
    Last edited: Jul 19, 2016
  48. screenname_taken

    screenname_taken

    Joined:
    Apr 8, 2013
    Posts:
    635
    Things seem to work with 9.3.3
     
    stonecompass likes this.
  49. screenname_taken

    screenname_taken

    Joined:
    Apr 8, 2013
    Posts:
    635
    To use that 2.0.2 Unity ads package that is in the asset store, do i just download and import?
    Or do i need to change any code?
    Also, when the asset gets integrated into the editor, will i have to delete the asset from the project?
     
  50. AVOlight

    AVOlight

    Joined:
    Apr 15, 2014
    Posts:
    401
    Last edited: Aug 23, 2016