Unity Ads Event.data Nil Value iOS

local function adListener( event )

    local json = require( "json" )

    local data = json.decode( event.data )

    if (data.placementId) == "rewardedVideo" and event.phase == "completed" then
	    if composer.getSceneName("current") == "scenes.home" then 
	    	  local getCoins = ssk.persist.get( "data.json", "coins" )
		      ssk.persist.set("data.json", "coins", getCoins + 50) 
	    elseif composer.getSceneName("current") == "scenes.game" then
		      ssk.persist.set("ads.json", "continueAd", true)
	    end
     end
end 

The following code works perfectly fine on Android, but when testing on Xcode and TestFlight I get a Runtime error saying event.data is a nil string. Anyone knows why and how to fix this?

It was an easy fix - simply having an if event.data ~= nil over the block of code.

What threw me off was the fact that in android you could have something like

json.decode(“random invalid string”)

and that would run without any errors, while on iOS it would give a runtime error.