HomeAppVirality DocsAndroid SDK IntegrationListeners & Interfaces

Listeners & Interfaces

AppVirality provides various interfaces with its SDK that can be used to receive a callback upon successful execution, or in case of some error while executing the API.

You can use these callbacks to: 

  • track the execution of the API
  • check if the API call is successful or not
  • receive API response data or some other data depending on the API
  • get error message in case the API call gets failed

Below is a full list of interfaces provided by the AppVirality SDK.
You can check them out to know their use case and callback parameters.

This interface is used to receive a callback while checking the attribution status for the user.

 
 void onResponse(JSONObject responseData, String errorMsg);

Callback method, called when the /checkforattribution API finishes execution.

This will only be called if you have requested for the callback, passing a valid CheckAttributionListener instance while checking the attribution status for a user.

 

Parameters

responseDataJSONObject. User attribution data returned by the API, null if the call fails

{
    "userKey": "ff86355995aa48b38b4f726b8383dd85",
    "userEmail": "",
    "isExistingUser": true,
    "hasReferrer": false,
    "referrerCode": "",
    "referrerName": "",
    "profileImage": "",
    "rewardType": "",
    "friendReward": "",
    "friendRewardUnit": "",
    "friendRewardEvent": "",
    "friendIncentiveDesc": "",
    "welcomeMessage": "",
    "offerTitleColor": "",
    "campaignBGColor": "",
    "offerDescriptionColor": "",
    "attributionSetting": "1",
    "isReferrerConfirmed": false,
    "isRewardExists": false
}

errorMsgString. Error message, if the API call gets failed; else NULL

Callback interface, for when the AppVirality SDK initialization API finishes execution.

This interface is used to receive a callback while initializing the AppVirality SDK.

  
  void onInitFinished(boolean isInitialized, JSONObject responseData, String errorMsg);      

Callback method, called when the AppVirality SDK initialization API finishes execution.

This will only be called if you have requested for the callback, passing a valid AppViralitySessionInitListener instance while initializing the SDK. The callback returns a bunch of details about the user, like: 

  • User Key (most important among all other details)
  • Whether user has a Referrer
  • Is an Existing User or not
  • Reward type for the user

Parameters

isInitializedboolean. True, if the SDK gets initialized successfully; else False
responseDataJSONObject. User attribution data returned by the API, null if the call fails

{
  "userKey": "19bbcd95cf5d4bf6ade8eb42fe7ef262",
  "customUrl": "",
  "customDomain": "",
  "isExistingUser": false,
  "hasReferrer": true,
  "referrerCode": "avg-4",
  "referrerName": "peter.raj990%40gmail.com",
  "profileImage": "",
  "rewardType": "3",
  "friendReward": "12",
  "friendRewardUnit": "Points",
  "friendRewardEvent": "Install",
  "friendIncentiveDesc": "",
  "welcomeMessage":  "12+Points+from+peter.raj990%40gmail.com.+Create+an+account+and+claim+your+credit+on+DEVTESTAPP.",
  "offerTitleColor": "#ffffff", 
  "campaignBGColor": "#e45335",
  "offerDescriptionColor": "#ffffff",
  "attributionSetting": "1",
  "isReferrerConfirmed": true,
  "success": true,
  "statusCode": 0,
  "Message": ""
}

errorMsgString. Error message, if the initialization fails; else NULL

Callback interface for notifying when the referrer details are ready.

This interface is used to receive a callback when the referrer details will be ready, returning the referrer details with the callback.

 
 void onReferrerDetailsReady(JSONObject referrerDetails);

Callback method, called when the referrer details will be ready with the SDK.

This will only be called if you have requested for the callback, passing a valid ReferrerDetailsReadyListener instance while invoking the SDK method to get the referrer details.

Parameters

referrerDetailsJSONObject. User attribution data returned by the API, null if the call fails

{
    "userKey": "ff86355995aa48b38b4f726b8383dd85",
    "userEmail": "",
    "isExistingUser": true,
    "hasReferrer": false,
    "referrerCode": "",
    "referrerName": "",
    "profileImage": "",
    "rewardType": "",
    "friendReward": "",
    "friendRewardUnit": "",
    "friendRewardEvent": "",
    "friendIncentiveDesc": "",
    "welcomeMessage": "",
    "offerTitleColor": "",
    "campaignBGColor": "",
    "offerDescriptionColor": "",
    "attributionSetting": "1",
    "isReferrerConfirmed": false,
    "isRewardExists": false
}

Callback interface for getting the campaign details.

This interface is used to receive a callback when the campaign details will be ready, returning the campaign details with the callback.

  
void onGetCampaignDetails(ArrayList<CampaignDetail> campaignDetails, boolean refreshImages, String errorMsg);

Callback method, called when the campaign details will be ready with the SDK.

This will only be called if you have requested for the callback, passing a valid CampaignDetailsListener instance while invoking the SDK method to get the campaign details.

Parameters

campaignDetailsArrayList<CampaignDetail>. Array list of CampaignDetail class objects, which contains various campaign related data like campaignId, campaignTitle, etc

refreshImagesboolean. True, if Word of Mouth campaign details are changed ; else False

NOTE: You must download all the Word of Mouth campaign images whenever you get this as True, as it would be provided only once on campaign details change

errorMsgString. Error message, if the API call to fetch campaigns gets failed ; else NULL

Callback interface for when the /updateappuserinfo API finishes execution.

This interface is used to receive a callback while updating the user info.

   
   void onResponse(boolean isSuccess, String errorMsg);<br>

Callback method, when the /updateappuserinfo API finishes execution.

This will only be called if you have requested for the callback, passing a valid UpdateUserInfoListener instance while invoking the SDK method to update the user info.

Parameters

isSuccessboolean. True, if the user info updated successfully ; else False

errorMsgString. Error message, if the API call gets failed ; else NULL

Callback interface for when the saveconversionevent API finishes execution.

This interface is used to receive a callback while saving a conversion event.

  
  void onResponse(boolean isSuccess, String message, String errorMsg);    

Callback method, when the /saveconversionevent API finishes execution.

This will only be called if you have requested for the callback, passing a valid ConversionEventListener instance while invoking the SDK method to save a conversion event.

Parameters

isSuccessboolean. True, if user got any reward for the event ; else False

messageString. Message to display if API call is successful

errorMsgString. Error message, if the API call gets failed ; else NULL

Callback interface for when the /setreferrercode API finishes execution.

This interface is used to receive a callback while submitting a referral code.

  
  void onResponse(boolean isSuccess, JSONObject responseData, String errorMsg);

Callback method, when the /setreferrercode API finishes execution.

This will only be called if you have requested for the callback, passing a valid SubmitReferralCodeListener instance while invoking the SDK method to apply referral code for a user.

Parameters

isSuccessboolean. True, if the referral code applied successfully ; else False

responseDataJSONObject. Submit Referral Code API response data

{
  "userKey": "19bbcd95cf5d4bf6ade8eb42fe7ef262",
  "customUrl": "",
  "customDomain": "",
  "isExistingUser": false,
  "hasReferrer": true,
  "referrerCode": "avg-4",
  "referrerName": "peter.raj990%40gmail.com",
  "profileImage": "",
  "rewardType": "3",
  "friendReward": "12",
  "friendRewardUnit": "Points",
  "friendRewardEvent": "Install",
  "friendIncentiveDesc": "",
  "welcomeMessage":  "12+Points+from+peter.raj990%40gmail.com.+Create+an+account+and+claim+your+credit+on+DEVTESTAPP.",
  "offerTitleColor": "#ffffff", 
  "campaignBGColor": "#e45335",
  "offerDescriptionColor": "#ffffff",
  "attributionSetting": "1",
  "isReferrerConfirmed": true,
  "success": true,
  "statusCode": 0,
  "Message": ""
}

errorMsgString. Error message, if the API call gets failed ; else NULL

Callback interface for when the /campaignterms API finishes execution.

This interface is used to receive a callback while fetching the terms for a campaign.

  
  void onGetCampaignTerms(String terms, String errorMsg);

Callback method, when the /setreferrercode API finishes execution.

This will only be called if you have requested for the callback, passing a valid CampaignTermsListener instance while invoking the SDK method to fetch terms for a campaign.

Parameters

termsString. Campaign terms, if terms are set on dashboard ; else NULL

errorMsgString. Error message, if the API call gets failed ; else NULL

Callback interface for when the /customizereferralcode API finishes execution.

This interface is used to receive a callback while customizing the user’s referral code.

  
  void onCustomRefCodeSet(boolean isSuccess, String errorMsg);

Callback method, when the /customizereferralcode API finishes execution.

This will only be called if you have requested for the callback, passing a valid CampaignTermsListener instance while invoking the SDK method to customize the referral code for a user.

Parameters

isSuccess – boolean. True, if referral code is customized successfully; else False

errorMsgString. Error message, if the API call gets failed ; else NULL

Callback interface for when the /getuserbalance API finishes execution.

This interface is used to receive a callback while fetching the reward balance for a user.

  
void onGetRewardDetails(JSONObject responseData, String errorMsg);  
Callback method, when the /getuserbalance API finishes execution.
This will only be called if you have requested for the callback, passing a valid UserBalanceListener instance while invoking the SDK method to fetch the reward balance for a user.

Parameters

responseDataJSONObject. Contains all rewards related data for a user i.e. claimed, pending, etc.; amount, coupon code, gross amount earned, etc.

{
  "userBalance": {
    "total": 33.0,
    "claimed": 0.0,
    "pending": 33.0,
    "approved": 33.0,
    "growthHacks": [{
      "ghName": "Word_of_Mouth",
      "total": 30.0,
      "claimed": 0.0,
      "pending": 30.0,
      "approved": 30.0,
      "campaigns": [{
        "campaignId": 431,
        "campaignName": "Faraz Referral Test",
        "total": 30.0,
        "claimed": 0.0,
        "pending": 30.0,
        "approved": 30.0,
        "ghName": "Word_of_Mouth",
        "rewardUnit": "coins"
      }]
    }, {
      "ghName": "Loyalty_Program",
      "total": 3.0,
      "claimed": 0.0,
      "pending": 3.0,
      "campaigns": [{
        "campaignId": 453,
        "campaignName": "LoyaltyTestCampaign",
        "total": 3.0,
        "claimed": 0.0,
        "pending": 3.0,
        "approved": 3.0,
        "ghName": "Loyalty_Program",
        "rewardUnit": "$"
      }]
    }]
  },
  "success": true,
  "statusCode": 0,
  "Message": ""
}

errorMsgString. Error message, if the API call gets failed ; else NULL

Callback interface for when the /getuserrewards API finishes execution.

This interface is used to receive a callback while fetching the detail reward data for a user.

  
void onResponse(JSONObject responseData, String errorMsg);  
Callback method, when the /getuserrewards API finishes execution.
This will only be called if you have requested for the callback, passing a valid UserRewardsListener instance while invoking the SDK method to fetch the detail reward data for a user.

Parameters

responseDataJSONObject. Contains detail reward data for a user.

{  
   "rewards":[  
      {  
         "name":"",
         "image":"",
         "email":"",
         "reward":"5.00",
         "rewardUnit":"Cust",
         "rewardedOn":"8-Dec-2016",
         "eventName":"Install",
         "rewardStatus":"Pending",
         "rewardType":"Coupon",
         "userType":"Referrer",
         "coupon":"",
         "campaignID":"431",
         "campaignName":"F Faraz Referral 2",
         "growthhack":"Word_of_Mouth",
         "couponimage":"",
         "coupondetails":"",
         "couponname":""
      },
      {  
         "name":"test236884name",
         "image":"",
         "email":"",
         "reward":"5.00",
         "rewardUnit":"Cust",
         "rewardedOn":"7-Dec-2016",
         "eventName":"Install",
         "rewardStatus":"Pending",
         "rewardType":"Coupon",
         "userType":"Referrer",
         "coupon":"",
         "campaignID":"431",
         "campaignName":"F Faraz Referral 2",
         "growthhack":"Word_of_Mouth",
         "couponimage":"",
         "coupondetails":"",
         "couponname":""
      },
      {  
         "name":"test236883name",
         "image":"",
         "email":"",
         "reward":"5.00",
         "rewardUnit":"Cust",
         "rewardedOn":"7-Dec-2016",
         "eventName":"Install",
         "rewardStatus":"Pending",
         "rewardType":"Coupon",
         "userType":"Referrer",
         "coupon":"",
         "campaignID":"431",
         "campaignName":"F Faraz Referral 2",
         "growthhack":"Word_of_Mouth",
         "couponimage":"",
         "coupondetails":"",
         "couponname":""
      },
      {  
         "name":"test236882name",
         "image":"",
         "email":"",
         "reward":"5.00",
         "rewardUnit":"Cust",
         "rewardedOn":"7-Dec-2016",
         "eventName":"Install",
         "rewardStatus":"Pending",
         "rewardType":"Coupon",
         "userType":"Referrer",
         "coupon":"",
         "campaignID":"431",
         "campaignName":"F Faraz Referral 2",
         "growthhack":"Word_of_Mouth",
         "couponimage":"",
         "coupondetails":"",
         "couponname":""
      },
      {  
         "name":"test236857name",
         "image":"",
         "email":"",
         "reward":"5.00",
         "rewardUnit":"Cust",
         "rewardedOn":"6-Dec-2016",
         "eventName":"Install",
         "rewardStatus":"Pending",
         "rewardType":"Coupon",
         "userType":"Referrer",
         "coupon":"",
         "campaignID":"431",
         "campaignName":"F Faraz Referral 2",
         "growthhack":"Word_of_Mouth",
         "couponimage":"",
         "coupondetails":"",
         "couponname":""
      },
      {  
         "name":"frnd2811655@dummy.com",
         "image":"",
         "email":"",
         "reward":"5.00",
         "rewardUnit":"Cust",
         "rewardedOn":"28-Nov-2016",
         "eventName":"Install",
         "rewardStatus":"Pending",
         "rewardType":"Coupon",
         "userType":"Referrer",
         "coupon":"",
         "campaignID":"431",
         "campaignName":"F Faraz Referral 2",
         "growthhack":"Word_of_Mouth",
         "couponimage":"",
         "coupondetails":"",
         "couponname":""
      },
      {  
         "name":"test236719name",
         "image":"",
         "email":"",
         "reward":"5.00",
         "rewardUnit":"Cust",
         "rewardedOn":"28-Nov-2016",
         "eventName":"Install",
         "rewardStatus":"Pending",
         "rewardType":"Coupon",
         "userType":"Referrer",
         "coupon":"",
         "campaignID":"431",
         "campaignName":"F Faraz Referral 2",
         "growthhack":"Word_of_Mouth",
         "couponimage":"",
         "coupondetails":"",
         "couponname":""
      },
      {  
         "name":"frnd2811330",
         "image":"",
         "email":"",
         "reward":"5.00",
         "rewardUnit":"Cust",
         "rewardedOn":"28-Nov-2016",
         "eventName":"Install",
         "rewardStatus":"Pending",
         "rewardType":"Coupon",
         "userType":"Referrer",
         "coupon":"",
         "campaignID":"431",
         "campaignName":"F Faraz Referral 2",
         "growthhack":"Word_of_Mouth",
         "couponimage":"",
         "coupondetails":"",
         "couponname":""
      },
      {  
         "name":"Frnd2811319",
         "image":"",
         "email":"",
         "reward":"5.00",
         "rewardUnit":"Cust",
         "rewardedOn":"28-Nov-2016",
         "eventName":"Install",
         "rewardStatus":"Pending",
         "rewardType":"Coupon",
         "userType":"Referrer",
         "coupon":"",
         "campaignID":"431",
         "campaignName":"F Faraz Referral 2",
         "growthhack":"Word_of_Mouth",
         "couponimage":"",
         "coupondetails":"",
         "couponname":""
      },
      {  
         "name":"test236501name",
         "image":"",
         "email":"",
         "reward":"5.00",
         "rewardUnit":"Cust",
         "rewardedOn":"18-Nov-2016",
         "eventName":"Install",
         "rewardStatus":"Pending",
         "rewardType":"Coupon",
         "userType":"Referrer",
         "coupon":"",
         "campaignID":"431",
         "campaignName":"F Faraz Referral 2",
         "growthhack":"Word_of_Mouth",
         "couponimage":"",
         "coupondetails":"",
         "couponname":""
      }
   ],
   "success":true,
   "Message":""
}

errorMsgString. Error message, if the API call gets failed ; else NULL

Callback interface for when the /getusercoupons API finishes execution.

This interface is used to receive a callback while fetching the coupons for a user.

  
  void onGetCoupons(boolean isSuccess, JSONArray userCoupons, String errorMsg);

Callback method, when the /getusercoupons API finishes execution.

This will only be called if you have requested for the callback, passing a valid UserCouponsListener instance while invoking the SDK method to fetch the coupons for a user.

Parameters

isSuccessboolean. True, if API call gets executed successfully; else NULL

userCouponsJSONArray. Array of user coupons data

[{
    "coupons": [{
    "couponCode": "Install123",
    "couponExpiry": "24-Jul-2016",
    "couponValue": "5",
    "couponUnit": "coins",
    "campaignID": "431",
    "campaignName": "Faraz Referral Test",
    "image": "https://paytm.com/blog/wp-content/uploads/2014/11/logo.png",
    "details": "Install Coupon Pool Dummy Test for Long description.",
    "name": "InstallCouponPool"
  }, {
    "couponCode": "Signup123",
    "couponExpiry": "24-Jul-2016",
    "couponValue": "7",
    "couponUnit": "coins",
    "campaignID": "431",
    "campaignName": "Faraz Referral Test",
    "image": "https://paytm.com/blog/wp-content/uploads/2014/11/logo.png",
    "details": "SignUp Coupon Pool",
    "name": "SignUpCouponPool"
  }]
}]

errorMsgString. Error message, if the API call gets failed ; else NULL

Callback interface for when the /getcouponpools API finishes execution.

This interface is used to receive a callback while fetching the coupon pools for a campaign, from which the user could redeem a coupon.

  
  void onGetCouponPools(JSONObject responseData, String errorMsg);
Callback method, when the /getcouponpools API finishes execution.
This will only be called if you have requested for the callback, passing a valid CouponPoolsListener instance while invoking the SDK method to fetch the coupon pools for a campaign, from which the user could redeem a coupon.

Parameters

responseDataJSONObject. Contains all coupon pool related data for a campaign including coupon pool details

{
  "campaigns": [{
    "campaignId": "431",
    "campaignName": "Faraz Referral Test",
    "growthhack": "Word_of_Mouth",
    "pools": [{
      "poolId": "141",
      "name": "SignUpCouponPool",
      "details": "SignUp Coupon Pool",
      "image": "https://paytm.com/blog/wp-content/uploads/2014/11/logo.png",
      "value": "7"
    }, {
      "poolId": "142",
      "name": "InstallCouponPool",
      "details": "Install Coupon Pool Dummy Test for Long description.",
      "image": "https://paytm.com/blog/wp-content/uploads/2014/11/logo.png",
      "value": "5"
    }, {
      "poolId": "143",
      "name": "TransactionCouponPool",
      "details": "Transaction Coupon Pool",
      "image": "https://paytm.com/blog/wp-content/uploads/2014/11/logo.png",
      "value": "3"
    }]
  }, {
    "campaignId": "453",
    "campaignName": "LoyaltyTestCampaign",
    "growthhack": "Loyalty_Program",
    "pools": [{
      "poolId": "160",
      "name": "InstallCouponPool",
      "details": "Install Coupon Pool Dummy Test for Long description.",
      "image": "https://paytm.com/blog/wp-content/uploads/2014/11/logo.png",
      "value": "5"
    }, {
      "poolId": "161",
      "name": "TransactionCouponPool",
      "details": "Transaction Coupon Pool",
      "image": "https://paytm.com/blog/wp-content/uploads/2014/11/logo.png",
      "value": "3"
    }, {
      "poolId": "162",
      "name": "SignUpCouponPool",
      "details": "SignUp Coupon Pool",
      "image": "https://paytm.com/blog/wp-content/uploads/2014/11/logo.png",
      "value": "7"
    }]
  }],
  "success": true,
  "statusCode": 0,
  "Message": ""
}

errorMsgString. Error message, if the API call gets failed ; else NULL

Callback interface for when the /redeemrewards API finishes execution.

This interface is used to receive a callback while redeeming a coupon from some coupon pool.

  void onResponse(boolean isRedeemed, String errorMsg);

Callback method, when the /redeemrewards API finishes execution.

This will only be called if you have requested for the callback, passing a valid CouponRedeemListener instance while invoking the SDK method to redeem a coupon from some coupon pool.

Parameters

isRedeemedboolean. True, if the coupon redeemed successfully ; else false

errorMsgString. Error message, if the API call gets failed ; else NULL

Callback interface for when the /getfriendslist API finishes execution.

This interface is used to receive a callback while fetching the list of friends for a user.

void onGetFriends(JSONObject responseData, String errorMsg);
Callback method, when the /getfriendslist API finishes execution.

This will only be called if you have requested for the callback, passing a valid GetFriendsListener instance while invoking the SDK method to fetch the list of friends for a user.

Parameters

responseDataJSONObject. Contains data related to the Friends Info for your Growth Campaign

{
  "friends": [{
    "appUserId": 235567,
    "emailId": "",
    "name": "",
    "profileImage": "",
    "regDate": "15-Jul-2016"
  }, {
    "appUserId": 235566,
    "emailId": "",
    "name": "test235566name",
    "profileImage": "",
    "regDate": "15-Jul-2016"
  }, {
    "appUserId": 235565,
    "emailId": "",
    "name": "test235565name",
    "profileImage": "",
    "regDate": "15-Jul-2016"
  }],
  "success": true,
  "statusCode": 0,
  "Message": ""
}

errorMsgString. Error message, if the API call gets failed ; else NULL

Callback interface for when the /recordproductattribution API finishes execution.

This interface is used to receive a callback while recording attribution for a shared product.

 
 void onResponse(JSONObject responseData, String errorMsg);
Callback method, when the /recordproductattribution API finishes execution.

This will only be called if you have requested for the callback, passing a valid ProductAttributionListener instance while invoking the SDK method to record the attribution for a product shared by someone with the user.

Parameters

responseDataJSONObject. Contains product related data

{
    "productCode": "SKUNIK3",
    "extraInfo": null,
    "success": true
}
 errorMsgString. Error message, if the API call gets failed ; else NULL

 

 

Was this article helpful to you? Yes No