Reward User

1. Fully Managed by MyChips

Use this method only if you have selected Self-Managed Currency. If you already support S2S postback please skip this snippet.

To check for a reward use the getReward function. It requires your adunitId, a reward callback(which will be called if the checks shows that there is a reward), and an on error callback.

MCOfferwallSDK.getReward(
    adunitId: "YOUR_AD_UNIT_ID") { reward in
        //do something with the reward, here we just print it
        print(reward.virtualCurrencyReward)
    } onError: { error in
        //do something with the error, here we just print it
        print(error)
    }
}

If there is no reward and no error, nothing will happen

You should check for the reward whenever the app is started or resumed. Example integration:

class SceneDelegate: UIResponder, UIWindowSceneDelegate {

    var window: UIWindow?
    
    var firstActive = true
    func sceneDidBecomeActive(_ scene: UIScene) {
        if (firstActive) {
            //at the app start initialize the sdk
            let _ = MCOfferwallSDK(apiKey: "YOUR_API_KEY")
            //optionally set user id
            MCOfferwallSDK.setUserId(userId: "YOUR_USER_ID")
            firstActive = false
        }
        
        //other the start or resume check for the reward and do something
        MCOfferwallSDK.getReward(
            adunitId: "YOUR_AD_UNIT_ID") { reward in
                print(reward.virtualCurrencyReward)
            } onError: { error in
                print(error)
            }
    }
    
    //...OTHER SCENEDELEGATE FUNCTIONS

}

2. Server-to-Server (S2S) Postbacks

If you prefer server-to-server communication, MyChips can send a postback to your server with bonus information. The configuration for postbacks is available in your publisher dashboard. This method is useful for validating and securely rewarding users without client-side manipulation.

Last updated