Getting started with bonuses🔗
Import
Included in the MRGService module. To use it, add the module to the project, and import the header file where needed.
Integration of bonuses into your application consists of just a few steps:
Step 1. Set delegate🔗
Upon starting the MRGS SDK, it is necessary to pass an object implementing the MRGSServerDataDelegate protocol to the initialization method. Also, you have to implement the methods of the delegate:
public class MasterController : MonoBehaviour, IMRGSServerDataDelegate
{
void Awake()
{
// Set basic MRGS parameters
// ...
// Call the initialization method, pass the delegate as the last parameter
MRGService.Instance.Initialize(serviceParams, sdkParams, this);
}
public void OnServerDataLoaded(string jsonString)
{
// Handle the server response.
Debug.Log("Received server data: " + jsonString);
}
}
@interface YourAppDelegate (MRGS) <MRGSServerDataDelegate>
@end
@implementation YourAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
// Set basic MRGS parameters
// ...
// Call the initialization method, passing the delegate as the third parameter
[MRGService startWithServiceParams:mrgsParams
externalSDKParams:@[myTrackerParams]
delegate:self];
}
#pragma mark - MRGSServerDataDelegate
- (void)loadServerDataDidFinished:(NSDictionary *)serverData {
// Handle the server response.
NSLog(@"%@ %@", NSStringFromSelector(_cmd), serverData);
}
public class YourApplicationClass extends Application implements MRGSServerDataDelegate
{
@Override
public void onCreate()
{
super.onCreate();
// Set basic MRGS parameters
//...
// Call the initialization method, pass the delegate as the last parameter
MRGService.service(context, settings, externalSdk, this);
}
@Override
public void loadServerDataDidFinished(MRGSMap serverData) {
// Handle the server response.
}
}
Step 2. Get data🔗
To request the latest data from the server, use the following method:
Automatic request
In addition, ServerData data will be requested and downloaded automatically during User Authorization.
The serverData dictionary looks as follows:
"Bonuses" : {
"2149879" : {
"code" : "money",
"id" : "2149879",
"object_id" : "1",
"cnt" : "200"
}
},
"Payments" : [
{
"id" : "13745540",
"atime" : "1531227425",
"userId" : "1234",
"transactionIdentifier" : "ru.akeb.framework.testConsumable",
"transactionId" : "1000000416060976"
}
],
"serverTime" : 1534328981,
"MinAppVersion" : "1.0.0"
}
From here you can get issues bonuses, server time, and pending payments.
Step 3. Give a bonus to a user🔗
If you give out bonuses on the client, then after issuing it is necessary to notify the MRGS server about this using the following method:
If your server gives bonuses, you have to notify the MRGS server about the bonus being given out through server API.
Created: 2020-02-17