Skip to content

Getting to work with MyGamesSupport🔗

To integrate MyGamesSupport you need to complete a few simple steps.

Step 1. Import the support module🔗

  • Add MRGSSupport module

    Unity:

    Adding to the project (general instruction)

    Step 1. Add Sources

    To add MRGS to a project via the Unity Package Manager (available from Unity 2018+) simply add a scopedRegistries section to the Packages/manifest.json file by adding the following entry:

    {
        "dependencies": {
            ...
        },
        "scopedRegistries": [
                {
                    "name": "MRGS",
                    "url": "https://mrgs-nexus.my.games/repository/mrgs-uninty-plugins/",
                    "scopes": [
                        "games.my.mrgs"
                    ]
                }
        ]
    }
    

    Alternatively, you can click Edit -> Project Settings -> Package Manager -> '+' in scoped registry section, and fill in the fields according to the data above.

    Step 2. Add dependency

    • Click Window -> Package Manager -> select 'Packages: MyRegistries' from dropdown list, select package MRGSSupport from the list, then click "Install"
    • Import the module: using MRGS;
    • Download the latest version of the library. Unzip the archive.
    • (For unitypackage integration) In Unity, click Assets -> Import Package -> Custom Package, and select the games.my.mrgs.support.unitypackage package from the downloaded archive.
    • (For tgz integration) In Unity, click Window -> Package Manager -> '+' -> Add package from tarball, and select the games.my.mrgs.support-<version> package. tgz from the downloaded archive.
    • Import the module: using MRGS;

    iOS:

    Adding to the project (general instruction)

    Step 1: Add dependencies

    Via Package collection

    • In Xcode select File > Add Packages
    • Select "+" > "Add Swift Package Collection"
    • Insert URL: https://mrgs-nexus.my.games/repository/ios-sdks/MRGSPackageCollection.json
    • Select module MRGSSupport from "MRGS Package Collection".
    • Or you can select "MRGS" package from "MRGS Package Collection" (contains all mrgs modules as products) and then select "MRGS/Support" product only.

    Individual packages

    • In Xcode select File > Add Packages
    • In the search bar at the top right, paste the URL: https://mrgs-gitea.my.games/mrgs/mrgssupport-ios-sdk.git
    • Add a module to your project
    • Or you can paste the url https://mrgs-gitea.my.games/mrgs/ios-sdks.git to include the "MRGS" package which contains all mrgs modules as products and then select only the product" MRGS/Support".

    Step 2: Add support for ObjectiveC categories

    • Set the -ObjC flag in the "Other linker Flags" field in the project settings.
    • Import the module in code: @import MRGServiceKit; or @import MRGSSupport; or #import <MRGSSupport/MRGSSupport.h>

    Step 1. Add Sources

    In your podfile, add sources to the top of the file:

    source 'https://github.com/CocoaPods/Specs.git' # For main repo
    source 'https://mrgs-gitea.my.games/mrgs/cocoapods-specs.git'  # For MRGS repo
    

    Step 2: Add dependencies

    Add the latest version of MRGSSupport to target:

    To add via subspecs:

    target 'MyProject' do
        pod 'MRGS', '~> 5.0.0', :subspecs => ['Support']
    end
    

    To add via individual modules:

    target 'MyProject' do
        pod 'MRGSSupport', '~> 5.0.0'
    end
    

    To add all mrgs modules:

    target 'MyProject' do
        pod 'MRGS/AllKits', '~> 5.0.0'
    end
    

    Step 3: Install dependencies

    • Run pod install (or pod install --repo-update if necessary)
    • Import the module in code: @import MRGServiceKit; or @import MRGSSupport; or #import <MRGSSupport/MRGSSupport.h>

    Step 1: Add dependencies

    Add the dependency to your Cartfile:

    binary "https://mrgs-nexus.my.games/repository/ios-sdks/MRGSSupport/MRGSSupport.json" ~> 5.0.0
    

    Step 2: Install dependencies

    • Run carthage update --use-xcframeworks
    • Add downloaded frameworks to your project (make sure "do not embed" option is enabled)
    • Set the -ObjC flag in the "Other linker Flags" field in the project settings.
    • Import the module in code: @import MRGServiceKit; or @import MRGSSupport; or #import <MRGSSupport/MRGSSupport.h>
    • Download the latest version of the library. Unzip the archive.
    • Add MRGSSupport.xcframework from the downloaded archive to your project (Drag the libraries to the "Linked frameworks and Libraries" section) (Also contains MRGSSupport.framework for compatibility - fat framework)

    • Set the -ObjC flag in the "Other linker Flags" field in the project settings.

    • Import the module in code: @import MRGSSupport; or #import <MRGSSupport/MRGSSupport.h>
    • Also, you can add the MRGServiceKit.h and module.modulemap files from the archive to your project, or specify the path to them in the project settings in the Build Settings -> Header search paths section. Now, instead of importing each of our frameworks separately, you can only import one header file: @import MRGServiceKit;

    Android:

    Adding to the project

    Add a dependency in build.gradle file:

    dependencies {
        def mrgsVersion = "6.x.x"
    
        implementation "games.my.mrgs:support:$mrgsVersion"
    }
    

    Copy the MRGSSupport.aar file into the libs directory of your project. Add the necessary dependencies into the build.gradle file

    dependencies {
        //...
        implementation(name: 'MRGSSupport', ext:'aar')
    
        implementation 'androidx.appcompat:appcompat:1.6.1'
    }
    

Step 2. Preliminary setup🔗

About security and authorization

The support widget may contain personal data of the user in correspondence. In order to precisely prevent unauthorized access to data, the support system must have an understanding that the user has the right to such actions. Best of all authorization or user verification is suitable for this (for example, in applications with authorization, the s2s server can receive real data about the user by accessToken, which cannot be faked from the client or from the outside), but since in many games the user is just a string identifier that cannot be confirmed with a username/password, then for such projects it is impossible to accurately verify the user, and for such cases you can only open the "anonymous" support page - it is tied to the bunch of userId and deviceID, this is allows you to guarantee the security of user data, since it is almost impossible to pick up such a bundle, but with this approach, when switching to a new device, the entire history of correspondence will be lost, unlike projects with authorization, since they can confirm the authenticity of the user. To confirm the user, you can use third-party authorization systems (for example, Facebook, VK, MyGames), as you can also get real data about the user using the accessToken without the possibility of forging them.

Thus, the support widget can be opened using two approaches:

  1. An authorized user, the details of which can be verified s2s - the correspondence is visible when entering from any device
  2. Using an "anonymous" account based on a bunch of userId and deviceID - the correspondence disappears when switching to another device

MRGS supports both approaches:

  1. If there are no additional settings, an "anonymous" record will be opened
  2. You can add authorization in a third-party system when you open the widget - we support MyGames, Facebook, VK. With such an opening, all the correspondence of the anonymous academic record, which was before the opening, is synchronized and linked with an account in a third-party system, allowing you to see the correspondence on any device. Moreover, when using the MRGSAuthentication module, network authorization is transferred to the widget automatically. (That is, as soon as the widget is opened with an account in a third-party network, we link them, and then the correspondence can be seen on any device, this will help in solving problems - you can ask the user to go, for example, to MyGames, and he will return the history of his correspondence with support, and support will see his old account)

Also, if the project has its own authorization, or it is possible to unambiguously verify the user, and it is necessary to make access to the correspondence extremely secure and closed only by authorization, the project itself can authorize the user in the support widget (1st method listed above). To do this, the project needs to get the authorization code itself via the S2S API from the MyGamesSupport server (stitching all the widget display parameters into it) , and pass it to MRGS when opening the widget - we also support this method.

Step 2.1. Adding system file permissions🔗

Since the user can send photos and files to the correspondence, as well as download them from the correspondence, appropriate permissions are required

Step 2.1.1. Setting permissions for iOS🔗

For iOS make sure to check that you applicatio has the NSCameraUsageDescription and NSPhotoLibraryUsageDescription settings in the Info.plist file of the application, since in the support window user may want to add a photo or a screenshot from his gallery. Example of the Info.plist for the mentioned fields:

<key>NSCameraUsageDescription</key>
<string>We use camera so you can send photo to support, if you have problems.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>We use photo library so you can send screenshot to support, if you have problems.</string>

Step 2.1.2 Setting permissions for Android🔗

For the correct work on Android you need to have READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE permissions. MRGSSupport module already includes this permission in its manifest. On Android 6 and later it will be automatically requested from the user, if the application does not have access to the external storage.

Step 2.1.3. Android permission request localization🔗

You can also pass the desired localization for the dialog boxes to explain why you need permissions to access the storage (only Android):

MRGSMyGamesSupport.Localization localization = new MRGSMyGamesSupport.Localization();

// The text of the message that will be shown to the user (player) if an error occurs while working with support.
localization.SetErrorDialogParams(string title, string message, string button)

// Explanation of why write access to the storage is needed.
localization.SetWritePermissionRationaleDialogParams(string title, string message, string okButton, string cancelButton);

// Explanation of how to enable the required permission in the settings.
localization.SetWritePermissionSettingsDialogParams(string title, string message, string settingsButton, string cancelButton)

// Setting to config before opening widget
var widgetConfig = new MRGSMyGamesSupport.WidgetConfig();
widgetConfig.DialogLocalization = localization;
import games.my.mrgs.support.MRGSMyGamesSupportLocalization;

final MRGSMyGamesSupportLocalization localization = MRGSMyGamesSupportLocalization.newInstance();

// The text of the message that will be shown to the user (player) if an error occurs while working with support.
localization.setErrorDialogParams(String title, String message, String button)

// Explanation of why write access to the storage is needed.
localization.setWritePermissionRationaleDialogParams(String title, String message, String okButton, String cancelButton);

// Explanation of how to enable the required permission in the settings.
localization.setWritePermissionSettingsDialogParams(String title, String message, String settingsButton, String cancelButton)

Step 2.2. Setting user game identifier🔗

Only when working via MRGS

In case you decide to receive the authorization code of the widget yourself, you can skip this step, since userId is hardcoded into the authorization code.

For the correct work of MyGamesSupport you need to set the user game ID before opening the support window. You can read about setting the user game ID in the "Connecting the SDK" section Unity, iOS, Android

How to specify a user other than the one was set to MRGS?

If you want to use a user ID different from the one set at MRGS startup to open the support window, you can set it using the method:

MRGSMyGamesSupport.Instance.CustomUserID = "user_1234567_id";
[MRGSMyGamesSupport sharedInstance].customUserID = @"user_1234567_id";
MRGSMyGamesSupport.getInstance().setCustomUserId("user_1234567_id");

Step 3. Show support widget🔗

Step 3.1. Setting widget display parameters🔗

Before showing a widget (a regular widget, a support window, a list of requests, or any other page), you can configure some display parameters:

  1. Widget theme: can be light, dark, dark orange, or automatically determined based on the device theme. By default, the light theme will open.
  2. Widget design language: if not installed, it will be selected automatically based on the device language. If an unsupported language is installed, the English localization will be selected.
  3. Additional user parameters: you can pass json with additional. information in the widget. (for example, indicate that this is a vip user)

Example for setting all parameters:

var widgetConfig = new MRGSMyGamesSupport.WidgetConfig();

// Optional. Set up the theme of the widget (Default value is Light).
widgetConfig.Theme = MRGSMyGamesSupport.WidgetTheme.DeviceTheme;

// Optional. Set up a language in ISO alpha-2 format (By default the device language will be used).
widgetConfig.Language = "fr";
// or use MRGS class helper
widgetConfig.Language = MRGSUtils.SystemLanguageToISO(SystemLanguage.English);

widgetConfig.ExtraParameters = "{\"vip\" : true}";
MRGSMyGamesSupportWidgetConfig* widgetConfig = [[MRGSMyGamesSupportWidgetConfig alloc] init];

// Optional. Set up the theme of the widget (Default value is Light).
widgetConfig.theme = MRGSMyGamesSupportWidgetThemeDeviceTheme;

// Optional. Set up a language in ISO alpha-2 format (By default the device language will be used).
widgetConfig.language = @"fr";

// Optional. Set up extra params in JSON format.
widgetConfig.extraParameters = @"{\"vip\" : true}";
import games.my.mrgs.support.MRGSMyGamesSupport;
import games.my.mrgs.support.MRGSMyGamesSupportWidgetConfig;

final MRGSMyGamesSupportWidgetConfig widgetConfig = MRGSMyGamesSupportWidgetConfig.newInstance();

// Optional. Set up the theme of the widget (Default value is Light).
widgetConfig.setTheme(MRGSMyGamesSupport.WidgetTheme.SYSTEM);

// Optional. Set up a language in ISO alpha-2 format (By default the device language will be used).
widgetConfig.setLanguage("fr");

// Optional. Set up extra params in JSON format.
widgetConfig.setExtraParameters("{\"vip\" : true}");

Setting the authorization code when you receive it yourself

In case you decide to get the widget's authorization code yourself, first you need to securely obtain the authorization code via S2S api MyGamesSupport, API description can be found here. Then, you need to put it in the settings object created above and pass it to the display methods (since when you directly authorize, the display parameters are hardwired into the authorization code, the rest of the settings in the configuration will not be applied):

var widgetConfig = new MRGSMyGamesSupport.WidgetConfig();
widgetConfig.AuthCode = "some_received_code";
MRGSMyGamesSupportWidgetConfig* widgetConfig = [[MRGSMyGamesSupportWidgetConfig alloc] init];
widgetConfig.authCode = @"some_received_code";
import games.my.mrgs.support.MRGSMyGamesSupport;
import games.my.mrgs.support.MRGSMyGamesSupportWidgetConfig;

final MRGSMyGamesSupportWidgetConfig widgetConfig = MRGSMyGamesSupportWidgetConfig.newInstance();
widgetConfig.setAuthCode("some_received_code");

Step 3.2. Adding third-party authorization🔗

Only when working via MRGS

In case you decide to receive the authorization code of the widget yourself, you can skip this step, since userId is hardcoded into the authorization code.

To access your account from any device and link an anonymous account and a social network account, you need to forward authorization to the widget. When using the MRGSAuthentication module, we will add authorization on the MyGames, Facebook, VK networks automatically. If your authorization is done on your own, you can transfer it to the widget using the method:

var widgetConfig = new MRGSMyGamesSupport.WidgetConfig();
// MyGames
var authMyGames = MRGSMyGamesSupportCredential.Create(MRGSMyGamesSupportCredential.SocialNetwork.MyGames, "some_token");
widgetConfig.AddAuthentication(authMyGames);

// Facebook
var authFacebook = MRGSMyGamesSupportCredential.Create(MRGSMyGamesSupportCredential.SocialNetwork.Facebook, "some_token");
widgetConfig.AddAuthentication(authFacebook);
MRGSMyGamesSupportWidgetConfig* widgetConfig = [[MRGSMyGamesSupportWidgetConfig alloc] init];

// MyGames
MRGSMyGamesSupportCredential* credentialMyGames = [MRGSMyGamesSupportCredential credentialWithSocialNetwork:kMRGSMyGamesSupportCredentialSocialNetworkMyGames token:@"fakeToken"];
[widgetConfig addAuthentication: credentialMyGames];

// Facebook
MRGSMyGamesSupportCredential* credentialFacebook = [MRGSMyGamesSupportCredential credentialWithSocialNetwork:kMRGSMyGamesSupportCredentialSocialNetworkFacebook token:@"fakeToken"];
[widgetConfig addAuthentication: credentialFacebook];
import games.my.mrgs.support.MRGSMyGamesSupport.Credential;
import games.my.mrgs.support.MRGSMyGamesSupportWidgetConfig;

final MRGSMyGamesSupportWidgetConfig widgetConfig = MRGSMyGamesSupportWidgetConfig.newInstance();

// MyGames
final Credential credentialMyGames = new Credential(Credential.SocialNetwork.MY_GAMES, "some_token");
widgetConfig.addAuthentication(credentialMyGames);

// Facebook
final Credential credentialFacebook = new Credential(Credential.SocialNetwork.FACEBOOK, "some_token");
widgetConfig.addAuthentication(credentialFacebook);

Adding a key for VK authorization

If you use authorization in VK (via MRGSAuthentication or forward it to the widget yourself), so that MRGS can validate the user, you need to add the service key of the VK application (section "Settings->Service access key" on the VK website) in MRGS admin panel in the "Integrations->VK Access Token" section.

Step 3.3 Selecting a page to display🔗

By default, the main page of the widget will be opened, but if necessary, you can specify a specific page/section of the widget, for example, a response view window, a specific request window, a feedback window, a custom path. You can see the full list in the MRGSMyGamesSupportWidgetPage class.

var widgetConfig = new MRGSMyGamesSupport.WidgetConfig();
widgetConfig.Page = MRGSMyGamesSupport.WidgetPage.TicketsList;

MRGSMyGamesSupport.Instance.Show(widgetConfig, error =>
{
    // Handle result here.
});
MRGSMyGamesSupportWidgetConfig* widgetConfig = [[MRGSMyGamesSupportWidgetConfig alloc] init];
widgetConfig.page = MRGSMyGamesSupportWidgetPage.ticketsListPage;

[[MRGSMyGamesSupport sharedInstance] showWidgetInView:presentationView config:widgetConfig completionHandler:^(NSError * _Nullable error) {
    // Handle result here.
}];
import androidx.annotation.Nullable;

import games.my.mrgs.MRGSError;
import games.my.mrgs.support.MRGSMyGamesSupport;
import games.my.mrgs.support.MRGSMyGamesSupportWidgetConfig;
import games.my.mrgs.support.MRGSMyGamesSupportWidgetPage;
import games.my.mrgs.utils.optional.Consumer;

final MRGSMyGamesSupportWidgetConfig widgetConfig = MRGSMyGamesSupportWidgetConfig.newInstance();
widgetConfig.setPage(MRGSMyGamesSupportWidgetPage.TICKETS_LIST);

MRGSMyGamesSupport.getInstance().show(activity, widgetConfig, new Consumer<MRGSError>() {
    @Override
    public void accept(@Nullable MRGSError error) {
        // Handle result here
    }
});

Feedback page

Please note that you can show the feedback box - a separate page for submitting feedback.

var widgetConfig = new MRGSMyGamesSupport.WidgetConfig();
widgetConfig.Page = MRGSMyGamesSupport.WidgetPage.Feedback;

MRGSMyGamesSupport.Instance.Show(widgetConfig, error =>
{
    // Handle result here.
});
MRGSMyGamesSupportWidgetConfig* widgetConfig = [[MRGSMyGamesSupportWidgetConfig alloc] init];
widgetConfig.page = MRGSMyGamesSupportWidgetPage.feedbackPage;

[[MRGSMyGamesSupport sharedInstance] showWidgetInView:presentationView config:widgetConfig completionHandler:^(NSError * _Nullable error) {
    // Handle result here.
}];
import androidx.annotation.Nullable;

import games.my.mrgs.MRGSError;
import games.my.mrgs.support.MRGSMyGamesSupport;
import games.my.mrgs.support.MRGSMyGamesSupportWidgetConfig;
import games.my.mrgs.support.MRGSMyGamesSupportWidgetPage;
import games.my.mrgs.utils.optional.Consumer;

final MRGSMyGamesSupportWidgetConfig widgetConfig = MRGSMyGamesSupportWidgetConfig.newInstance();
widgetConfig.setPage(MRGSMyGamesSupportWidgetPage.FEEDBACK);

MRGSMyGamesSupport.getInstance().show(activity, widgetConfig, new Consumer<MRGSError>() {
    @Override
    public void accept(@Nullable MRGSError error) {
        // Handle result here
    }
});

Step 3.4 Open Support Widget🔗

After setting the display parameters, you need to call the display method:

The process for opening the support window is shown below:

MRGSMyGamesSupport.Instance.Show(config, error =>
{
    // Handle result here.
});
[[MRGSMyGamesSupport sharedInstance] showWidgetInView:presentationView config:widgetConfig completionHandler:^(NSError * _Nullable error) {
    // Handle result here.
}];
import androidx.annotation.Nullable;

import games.my.mrgs.MRGSError;
import games.my.mrgs.support.MRGSMyGamesSupport;
import games.my.mrgs.utils.optional.Consumer;

MRGSMyGamesSupport.getInstance().show(activity, widgetConfig, new Consumer<MRGSError>() {
    @Override
    public void accept(@Nullable MRGSError error) {
        // Handle result here.
    }
});

Statistics

When using our methods, MRGS automatically collects statistics on errors in the widget using MRGSMetrics (metricID -18)

Step 4. Checking responses from MyGamesSupport🔗

Only when working via MRGS

When receiving the authorization code for the widget yourself, the functionality of checking answers from the support service is not available.

The process for checking answers to user questions is presented below:

MRGSMyGamesSupport.Instance.CheckTickets((int numberOfUnread, MRGSError error) => {
    // Handle result here.
});

// Async/await way
var (unread, error) = await MRGSMyGamesSupport.Instance.CheckTicketsAsync();
var unread = await MRGSMyGamesSupport.Instance.CheckTicketsAsync().Throwable();
[[MRGSMyGamesSupport sharedInstance] checkTicketsWithCompletionHandler:^(NSNumber * _Nonnull numberOfUnreadTickets, NSError * _Nullable error) {
    // Handle result here.
}];
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import games.my.mrgs.MRGSError;
import games.my.mrgs.support.MRGSMyGamesSupport;
import games.my.mrgs.utils.optional.BiConsumer;

MRGSMyGamesSupport.getInstance().checkTickets(new BiConsumer<Integer, MRGSError>() {
    @Override
    public void accept(@NonNull Integer integer, @Nullable MRGSError error) {
        // Handle result here.
    }
});

Step 5: Receive support response notifications🔗

If you have integrated our notification module, the user will receive notifications about support responses. In order for the user to be taken to the support widget on the desired page when clicking on this notification, it is necessary to install a delegate and open the selected page at a convenient time:

private class NotificationSupportDelegate : MRGSMyGamesSupport.INotificationDelegate
{
    public void OnReceiveShowIntent(MRGSMyGamesSupport.WidgetPage page)
    {
        var config = new MRGSMyGamesSupport.WidgetConfig()
        {
            Theme = MRGSMyGamesSupport.WidgetTheme.Dark,
            Page = page
        };

        MRGSLog.Instance.AddLog("Opening support view with params:\n"+config);
        MRGSMyGamesSupport.Instance.Show(config, error =>
        {
            MRGSLog.Instance.AddLog("Closed support view." + (error != null ? "With error - " + error : ""));
        });
    }
}

MRGSMyGamesSupport.Instance.NotificationDelegate = new NotificationSupportDelegate();
[MRGSMyGamesSupport sharedInstance].notificationDelegate = self;

- (void)didReceiveShowIntentForPage:(MRGSMyGamesSupportWidgetPage*)page{
  NSLog(@"Received didReceiveShowIntentForPage delegate callback with page - %@", page);
}
MRGSMyGamesSupportNotificationListener supportNotificationListener = new MRGSMyGamesSupportNotificationListener() {
    @Override
    public void onReceiveShowIntentForPage(@NonNull MRGSMyGamesSupportWidgetPage page) {
        MRGSMyGamesSupportWidgetConfig config = MRGSMyGamesSupportWidgetConfig.newInstance();
        config.setPage(page);
        MRGSMyGamesSupport.getInstance().show(Activity.this, config);
    }
};
MRGSMyGamesSupport.getInstance().setSupportNotificationListener(supportNotificationListener);

If you do not have an integrated notification module from MRGS, you can catch such notifications yourself, their format is indicated below:

{
    "ref": "support",
    "url": "/#/ticket/123456"
}

Where:

  • "ref" - a required parameter, with the value "support".
  • "url" - required parameter, a string of the format "/#/ticket/$ticket_number" which specifies the ticket number.

Last update: 2023-12-28
Created: 2020-02-17