iOS SDK Connection🔗
Minimum requirements🔗
Minimum supported versions: iOS 11.0 and XCode 14.1.
Integration🔗
To integrate the MRGS library you need to complete five simple steps:
Step 1. Add the library to the project🔗
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 MRGService from "MRGS Package Collection".
- Or you can select "MRGS" package from "MRGS Package Collection" (contains all mrgs modules as products) and then select "MRGS/Core" 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/mrgservice-ios-sdk.git - Add a module to your project
- Or you can paste the url
https://mrgs-gitea.my.games/mrgs/ios-sdks.gitto include the "MRGS" package which contains all mrgs modules as products and then select only the product" MRGS/Core".
Step 2: Add support for ObjectiveC categories
- Set the
-ObjCflag in the "Other linker Flags" field in the project settings. - Import the module in code:
@import MRGServiceKit;or@import MRGService;or#import <MRGService/MRGService.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 MRGService to target:
To add via subspecs:
To add via individual modules:
To add all mrgs modules:
Step 3: Install dependencies
- Run
pod install(orpod install --repo-updateif necessary) - Import the module in code:
@import MRGServiceKit;or@import MRGService;or#import <MRGService/MRGService.h>
Step 1: Add dependencies
Add the dependency to your Cartfile:
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
-ObjCflag in the "Other linker Flags" field in the project settings. - Import the module in code:
@import MRGServiceKit;or@import MRGService;or#import <MRGService/MRGService.h>
- Download the latest version of the library. Unzip the archive.
-
Add
MRGService.xcframeworkfrom the downloaded archive to your project (Drag the libraries to the "Linked frameworks and Libraries" section) (Also contains MRGService.framework for compatibility - fat framework) -
Set the
-ObjCflag in the "Other linker Flags" field in the project settings. - Import the module in code:
@import MRGService;or#import <MRGService/MRGService.h> - Also, you can add the
MRGServiceKit.handmodule.modulemapfiles from the archive to your project, or specify the path to them in the project settings in theBuild Settings -> Header search pathssection. Now, instead of importing each of our frameworks separately, you can only import one header file:@import MRGServiceKit;
Note
The necessary system frameworks will be added to the linker parameters automatically (For this functionality to work in the "Build settings" section, the Link Frameworks Automatically field must be set to true), but in case this functionality does not work, below is a list of system libraries, from which the MRGS SDK depends on: AdSupport, SystemConfiguration, CoreTelephony, CoreData, CoreLocation, iAd, StoreKit.
Step 2. Call the initialization method🔗
Call the initialization method [MRGService startWithServiceParams:] in the didFinishLaunchingWithOptions method of your AppDelegate. As arguments, you need to specify MRGS_APP_ID, CLIENT_SECRET.
@import MRGService;
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// MRGService settings
MRGServiceParams *mrgsParams = [[MRGServiceParams alloc] initWithAppId: <MRGS_APP_ID> secret: <CLIENT_SECRET>];
// Start MRGS
[MRGService startWithServiceParams:mrgsParams];
}
MRGS_APP_ID and CLIENT_SECRET
MRGS_APP_ID - Application ID on the MRGS website. CLIENT_SECRET - Client Key. You can get them from the MRGS website, in the settings section of your application.
Important! Do not forget that these parameters are different for Android and iOS builds. Use the correct initialization keys:

Attention! Calling any methods (except the GDPR) before calling the start sdk method can lead to undefined MRGS behavior. Be careful not to start working with MRGS before calling the initialization method!
Using Headers
We support C-Modules, a technology for smart import of header files, which speeds up the assembly of the application. Each of our frameworks is represented by a corresponding module, so for import you can use a construct like #import <MRGSBank/MRGSBank.h> or @import MRGSBank;
User tracking request on iOS 14+
In case you want to show a popup of a request for tracking permissions (getting IDFA) in iOS 14, you can use our display methods. Usually IDFA is required for ad tracking, you can read more on the link above.
Step 3 (Optional); Add account login tracking🔗
If your application uses a player identifier (USER_ID), it must be passed to MRGS using the method:
Step 4. Add payment tracking🔗
By default, MRGS will automatically collect all payment data using autotracking, no further action is required.
Important
- Payment tracking is necessary if you do not use the MRGSBilling module.
- Make sure that on the site https://mrgs.astrum.team, in the settings of your application, the fields with keys for validating payments are filled in and the setting "Only validation of payments (without processing)" is enabled.
- MRGS will automatically send information about purchases to all the configured SDK (AppsFlyer, Firebase, MyTracker) if the corresponding modules are enabled
- Autotracking is automatically disabled when using MRGSBank module.
If you do not want to use auto-tracking, then you need to turn off automatic payment tracking, and use the method for direct transfer of payment data (not recommended approach):
// MRGService settings on SDK start
mrgsParams.automaticPaymentTracking = false;
// Tracking payment when it happens
[MRGSMetrics sendPaymentInfoForProduct: <SKProduct* object> transaction: <SKPaymentTransaction* object>];
Step 5. Add Deeplink tracking🔗
In order to track Deeplink(And also for the correct operation of some MRGS modules), you must add the following code to AppDelegate:
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[MRGService application:application didFinishLaunchingWithOptions:launchOptions];
return YES;
}
-(BOOL) application:(UIApplication *)application openURL:(nonnull NSURL *)url options:(nonnull NSDictionary<NSString *,id> *)options
{
[MRGService application:application openURL:url options:options];
return YES;
}
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler{
return [MRGService application:application continueUserActivity:userActivity restorationHandler:restorationHandler];
}
If the UIWindowSceneDelegate mechanism is used (iOS 13 and higher):
@implementation SceneDelegate
-(void)scene:(UIScene *)scene openURLContexts:(NSSet<UIOpenURLContext *> *)URLContexts{
[MRGService scene: scene openURLContexts: URLContexts];
}
-(void)scene:(UIScene *)scene continueUserActivity:(NSUserActivity *)userActivity{
[MRGService scene: scene continueUserActivity: userActivity];
}
Integration check🔗
After completing the MRGS integration, we recommend that you verify that the library is working correctly. To learn how to perform this procedure, see Integration checks and troubleshooting section.
Created: 2020-01-20